我有一张桌子"诗"字段"日期","内容"等
我想了解最近日期字段的内容。
$sql="select content, max(dated) as latestDate from poem";
这不起作用。
答案 0 :(得分:1)
如果您只需要一行,请使用order by
和limit
:
select p.*
from poem p
order by dated desc
limit 1;
如果您想要所有具有最新日期的行:
select p.*
from poem p
where p.dated = (select max(dated) from poem);
答案 1 :(得分:1)
您只需按日期排序
SELECT * FROM TABLENAME ORDER BY DATE DESC