本文介绍了我的SQL Server中的LIMIT子句问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有以下情况 + -------- + -------- + ------- ---------- + ------------------------- + | Msgid |用户ID |消息| MsgDate | + -------- + -------- + ----------------- + --- ---------------------- + | 3 | 75 | TextMSG | 2014-04-01 12:05:29.957 | | 4 | 75 | TextMSG | 2014-04-01 12:06:14.967 | | 5 | 75 | TextMSG | 2014-04-01 12:06:48.160 | | 6 | 80 | TextMSG | 2014-04-01 12:07:02.227 | | 7 | 80 | TextMSG | 2014-04-01 12:07:07.763 | + -------- + --------- + ------- + --- ------------------------------- + 并写用于检索用户ID 75的最近2个消息的查询。 SELECT Msg FROM TempNoti WHERE UserID = 75 LIMIT 2 ORDER BY MsgDate DESC ; 但它出现以下错误 'LIMIT'附近的语法不正确。 我使用本网站的教程mysqltutorial 。解决方案 I have the following scenario+--------+--------+-----------------+-------------------------+| Msgid |UserID | Msg | MsgDate |+--------+--------+-----------------+-------------------------+| 3 | 75 | TextMSG | 2014-04-01 12:05:29.957 || 4 | 75 | TextMSG | 2014-04-01 12:06:14.967 || 5 | 75 | TextMSG | 2014-04-01 12:06:48.160 || 6 | 80 | TextMSG | 2014-04-01 12:07:02.227 || 7 | 80 | TextMSG | 2014-04-01 12:07:07.763 |+--------+---------+-------+----------------------------------+and write the query to retrieve the 2 recent msg of User id 75.SELECT Msg FROM TempNoti WHERE UserID = 75 LIMIT 2 ORDER BY MsgDate DESC;But it gives the following errorIncorrect syntax near 'LIMIT'.I using the tutorial from this site mysqltutorial. 解决方案 这篇关于我的SQL Server中的LIMIT子句问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!