我已经实现了这个sql语句:
SELECT users.firstname, users.lastname, users.screenname, profile.profile_pic,
users.user_id, messages.msgid, messages.message, messages.action,
DATE_FORMAT(messages.date_sent, '%M %d, %Y %r') AS date_sent
FROM messages messages
JOIN users ON messages.sent_by = users.user_id
LEFT JOIN profile ON (users.user_id = profile.user_id)
WHERE messages.recepient_id = "12052821" and messages.action = false
ORDER BY msgid DESC
它向我输出正确的输出(下)
问题是您如何整理所有向您发送消息的用户列表并分别显示前 1 条消息 ORDER BY by msgid DESC?(用户不得重复)
这是我的桌子
我想我上面的查询需要一些改进。提前谢谢你们