宇筱博客

  • 解决办法
  • 学无止境
  • 记录时光
  • 百宝箱
宇筱博客
点滴记忆,汇聚成海。
  1. 首页
  2. 解决办法
  3. 正文

MySQL查询---排序后取第一条数据

2022年11月1日 167点热度 0人点赞 0条评论
select * from table_name where column_name=#{xxx} order by column_name limit 1 ;
select * from table_name where column_name=#{xxx} order by column_name limit 0,1;

limit 1 与 limit 0,1 是一样的!
换句话说,

比如 limit 3,是从查出来的结果中取 前3条数据;
而limit 0,3 是取
第0,
第1,
第2条 数据,
可以理解为 从第0条开始,取3条数据
也是三条数据

所以 LIMIT n 等价于 LIMIT 0,n

原文连接:点击进入

Post Views: 118
标签: 暂无
最后更新:2022年11月1日

小渔民

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2023 宇筱博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

豫ICP备15017825号-2