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;