按DateTime值排序MySql结果

时间:2018-02-10 00:37:04

标签: php mysql

我想通过DateTime值来订购MySQL查询的结果,该值位于每个列的'timestamp'列下。

我尝试添加

$reactions     = DB::query('SELECT * FROM reactions WHERE poster_id=:userid', array(':userid' => $userid));
$comments      = DB::query('SELECT * FROM comments WHERE poster_id=:userid', array(':userid' => $userid));
$mentions      = DB::query('SELECT * FROM comments WHERE FIND_IN_SET(:users , users)', array(':users' => $userid));
$postMentions  = DB::query('SELECT * FROM posts WHERE FIND_IN_SET(:users , users)', array(':users' => $userid));
$likedMessages = DB::query('SELECT * FROM messages WHERE sender_id:senderid AND liked=:liked', array(':senderid' => $userid, ':liked' => 1));
$reports       = DB::query('SELECT * FROM reports WHERE user_id=:userid AND status=:status OR status=:status2', array(':user_id' => $userid, ':status' => 1, ':status2' => 2));

但这根本不是他们的命令。

修改

更清楚;我想结合查询中的所有结果,然后通过时间戳

命令

1 个答案:

答案 0 :(得分:2)

在查询结尾处使用order by

ORDER BY `timestamp` DESC