用于显示表名的复杂 sql 语句 [英] Complex sql statement for showing the table names
问题描述
我有一个数据库,其中包含名为 Mark、Mask、Matk、Mauk 的表每个表都有一些列和一个名为 date 的列,其中当前日期以 php 的 date("h:i:sa d/m/Y") 格式存储.
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.
现在我想选择最后一列的日期距现在不到 5 分钟的表名称.我希望你能理解我的上述声明.
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.
我知道最后一部分我必须这样做:TIMESTAMP(NOW())-TIMESTAMP(Last columns date) <300.但是我不能做其他部分.P.S 我在 C# 应用程序中使用数据库.
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.
编辑:我猜代码应该是这样的:SHOW TABLES FROM db WHERE NOW()-SELECT
dateFROM TABLES ORDER BY dateDESC 限制 1 <= 300
EDIT:I'm guessing the code should be something like this:SHOW TABLES FROM db WHERE NOW()-SELECT
dateFROM TABLES ORDER BY date DESC LIMIT 1 <= 300
推荐答案
省略 timestamp
部分怎么样?
where LastColumnDate >= now() - interval 5 minute
我假设您根据示例代码使用 MySQL.
I am assuming you are using MySQL based on your sample code.
这篇关于用于显示表名的复杂 sql 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!