错误写法:
SELECT * FROM
(SELECT a.id, a.send_id, b.fullname AS sendName, a.receive_id, c.fullname AS receiveName, a.content, a.creation_date
FROM cy_biz_message a
LEFTJOIN sys_user b ON a.send_id = b.id
LEFTJOIN sys_user c ON a.receive_id = c.id
WHERE a.receive_id = 1025ORDERBY a.creation_date DESC) AS t
GROUPBY t.send_id ORDERBY t.creation_date DESC;
正确写法:
SELECT * FROM
(SELECT a.id, a.send_id, b.fullname AS sendName, a.receive_id, c.fullname AS receiveName, a.content, a.creation_date
FROM cy_biz_message a
LEFTJOIN sys_user b ON a.send_id = b.id
LEFTJOIN sys_user c ON a.receive_id = c.id
WHERE a.receive_id = 1025ORDERBY a.creation_date DESC LIMIT 10000) AS t
GROUPBY t.send_id ORDERBY t.creation_date DESC;