扫码关注官方订阅号
比如有id为1-10 共10条数据,现在想要根据传如的id来查询该指定id后的5条数据,
比如传入id为1,则查询出id为1,2,3,4,5 的数据,如果传入id为3,则查询出id为3,4,5,6,7 的数据
如何写?谢谢
ringa_lee
以users表为例:
\DB::table('users') -> where('id', '>=', $id) -> orderBy('id') -> take(5) -> get();
where id >=1 and id <=5where id >=3 and id <=7
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
以users表为例:
where id >=1 and id <=5
where id >=3 and id <=7