Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL通过不显示最后一行进行排序_Mysql_Sql Order By_Coalesce - Fatal编程技术网

MySQL通过不显示最后一行进行排序

MySQL通过不显示最后一行进行排序,mysql,sql-order-by,coalesce,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 `

我有以下疑问:

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的行。如何修复此问题?

您确定id字段是整数,因为varchar 5中的值大于128?如果不存在,请创建表
消息
id
int(11)NOT NULL自动递增,
type
varchar(60)COLLATE cp1250\u捷克语cs NOT NULL,
datum
int(11)NOT NULL,
read
int(11)不为空,
from
int(11)不为空,
to
int(11)不为空,
emotion
int(11)不为空,
ip
varchar(60)校对cp1250_捷克_cs NOT NULL,
message
longtext校对cp1250_捷克_cs NOT NULL,
nazev
text校对cp1250_捷克_cs NOT NULL,
cesta
text校对cp1250_捷克_cs NOT NULL,主键(
id
)引擎=InnoDB默认字符集=cp1250校对=cp1250捷克_cs自动增量=188;由于varchar 5大于128,您确定id字段是整数吗?如果不存在,请创建表
消息
id
int(11)NOT NULL自动递增,
type
varchar(60)COLLATE cp1250_捷克语cs NOT NULL,
datum
int(11)NOT NULL,
read
int(11)NOT NULL,
from
int(11) 不为空,
to
int(11)不为空,
emotion
int(11)不为空,
ip
varchar(60)校对cp1250_捷克_cs NOT NULL,
message
longtext校对cp1250_捷克_cs NOT NULL,
nazev
text校对cp1250_捷克_cs NOT NULL,
cesta
text校对cp1250_捷克_cs NOT NULL,主键(
id
)引擎=InnoDB默认字符集=cp1250校对=cp1250捷克_cs自动增量=188;