题解 | #查询结果限制返回行数#

查询结果限制返回行数

http://www.nowcoder.com/practice/c7ad0e2df4f647dfa5278e99894a7561

limit的三种写法:

select device_id from user_profile limit 2;
select device_id from user_profile limit 0, 2;
select device_id from user_profile limit 2 offset 0;

各位大神,还有其他写法吗?求指教

全部评论
select device_id from user_file wehere id in (1,2);
2 回复 分享
发布于 2022-11-27 18:26 浙江
SELECT device_id FROM user_profile WHERE id < 3
1 回复 分享
发布于 2022-12-27 15:15 湖南
select device_id from user_file where id=1 or id=2; select device_id from user_file where id<=2;
1 回复 分享
发布于 2022-10-26 15:10 北京
开窗函数
1 回复 分享
发布于 2022-10-06 16:52 广东
select a.device_id from (select device_id,row_number() over(order by id) t_rank from user_profile) a where a.t_rank<=2;
1 回复 分享
发布于 2022-10-06 16:52 广东

相关推荐

投递三奇智元机器人科技有限公司等公司10个岗位
点赞 评论 收藏
分享
notbeentak...:孩子,说实话,选择很重要,可能你换一个方向会好很多,但是现在时间不太够了,除非准备春招
点赞 评论 收藏
分享
头像
10-27 15:50
门头沟学院 Java
点赞 评论 收藏
分享
评论
35
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务