SQL查询数据库中的最新日期

时间:2011-02-10 09:40:52

标签: sql mysql sqlite

你能帮我构建一个sql查询,它从数据库中提取出最新日期的条目。

我尝试了但是来了dephnd

SELECT *
FROM Table t,Table t2
WHERE t.date>t2.date

我想我必须使用一些临时表...这对我来说有点困难

2 个答案:

答案 0 :(得分:6)

检索按日期排序的行,降序:

SELECT * FROM table ORDER BY date DESC

检索具有最新日期的5行:

SELECT * FROM table ORDER BY date DESC LIMIT 5

答案 1 :(得分:2)

尝试:

select * from Table where date_column = (select max(date_column) from Table)