我是MySQL的新手,我正在尝试按日期订购消息。我还希望显示不超过10条消息。我的问题:
$sql2 = "SELECT `id`, `Afbeelding`, `Vraag`, DATE_FORMAT(date, '%d-%m-%Y %H:%i:%s') FROM vraagstellen ORDER BY date DESC LIMIT 10";
订单被禁用。谁可以帮助我?谢谢!
答案 0 :(得分:0)
试试这个
$sql2 = "SELECT `id`, `Afbeelding`, `Vraag`, DATE_FORMAT(date, '%d-%m-%Y %H:%i:%s') as date_formatted FROM vraagstellen ORDER BY date DESC LIMIT 10";
您的代码:
$sql2 = "SELECT `id`, `Afbeelding`, `Vraag`, DATE_FORMAT(date, '%d-%m-%Y %H:%i:%s') FROM vraagstellen ORDER BY date DISC LIMIT 10";
as date_formatted
答案 1 :(得分:0)
更改
ORDER BY date DISC
到
ORDER BY date DESC
答案 2 :(得分:0)
将DISC更改为DESC
尝试使用:ORDER BY date DESC LIMIT 10
$sql2 = "SELECT id, Afbeelding, Vraag, DATE_FORMAT(date, '%d-%m-%Y %H:%i:%s') as newdate FROM vraagstellen ORDER BY newdate DESC LIMIT 10";
现在使用date
newdate
字段