项目中有一个业务需求是:默认载入15条历史记录(按时间顺序从早到晚)。
以下是我构造的sql逻辑,mark一下,亲測可行。
SELECT * FROM (SELECT *FROM group_chatmsg_v WHERE ((group_Id=46 AND send_user_id=28 AND receive_user_id=70) OR (group_Id=46 AND receive_user_id=28 AND STATUS=1)) AND is_delete =0 ORDER BY crtime DESC LIMIT 15) AS chatMsgTable ORDER BY crtime ASC
时间: 2024-10-31 15:12:18