免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 12462 | 回复: 4
打印 上一主题 下一主题

mysql 的limit 问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 14:12 |只看该作者 |倒序浏览
5可用积分
我就想知道  

  limit的第二个参数 到底可不可以为 -1


  limit 10,-1 是不是能查出从10到最后一条

  网上的帖子都说可以, 但是在客户端测试确实不行


  高手请给出确切答案  


论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2011-12-23 16:20 |只看该作者
不行  报错

mysql> select * from uc_pms limit 10,-1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1

论坛徽章:
4
CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52戌狗
日期:2013-12-27 15:08:11
3 [报告]
发表于 2011-12-23 16:39 |只看该作者
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 3
SELECT *
FROM `movie_busi_cart`
LIMIT 10 , -1

确实不能 如果要用到最后几条记录 可以加个order by  主键嘛 desc limit n

论坛徽章:
0
4 [报告]
发表于 2013-11-14 14:33 |只看该作者
你这是不看文档的结果

http://dev.mysql.com/doc/refman/5.5/en/select.html


The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants, with these exceptions:

    Within prepared statements, LIMIT parameters can be specified using ? placeholder markers.

    Within stored programs, LIMIT parameters can be specified using integer-valued routine parameters or local variables as of MySQL 5.5.6.

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP