标签:
项目中有一个业务需求是:默认载入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
略微复杂的sql逻辑(从数据库逆序查找有限条记录(limit))并按相反顺序输出
标签:
原文地址:http://www.cnblogs.com/gcczhongduan/p/5206772.html