MySQL ORDER BY没有显示最后一行

时间:2016-05-27 14:55:41

标签: mysql sql-order-by coalesce

我有以下查询:

MySQL_Query(
    "SELECT COALESCE(`from`,`to`) AS `userid`, `id`, `from`, `to`, `type`, `datum`, `read`, `message` 
     FROM `messages` 
     WHERE `to`='".$user->id."' 
     AND `from` NOT IN 
        (SELECT `user` FROM `ignore` WHERE `idu`='".$user->id."') 
     OR `from`='".$user->id."' 
     GROUP BY `userid` ORDER BY `id` DESC"
);

我拥有的最高ID为128,但PHP返回ID = 5的行。我该如何解决这个问题?

0 个答案:

没有答案