wingerse
wingerse

Reputation: 3796

Complex sql statement for showing the table names

I have a database with tables named Mark, Mask, Matk, Mauk Each tables have some columns and a column named date where the current date is stored in the php's date("h:i:sa d/m/Y") format.

Now I want to select the table names whose last column's date is less than 5 mins away from now. I hope you understand my above statement.

I know I would have to do this for the last part: TIMESTAMP(NOW())-TIMESTAMP(Last columns date) < 300. However I couldn't do the other parts. P.S I am using the database in a C# app.

EDIT:I'm guessing the code should be something like this:SHOW TABLES FROM db WHERE NOW()-SELECTdateFROM TABLES ORDER BY date DESC LIMIT 1 <= 300

Upvotes: 0

Views: 49

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270773

How about leaving out the timestamp part?

where LastColumnDate >= now() - interval 5 minute

I am assuming you are using MySQL based on your sample code.

Upvotes: 0

Related Questions