首页
留言板
友情链接
Search
1
【javascript】JS-向当前url追加参数
2,327 阅读
2
【PHP】生成随机昵称
2,188 阅读
3
【PHP】判断一个字符串是否属于序列化后的数据
2,017 阅读
4
【css】html+css给文章页,做阅读全文
1,957 阅读
5
【PHP】 设计模式(23种)
1,898 阅读
默认分类
typecho
代码改变世界
mysql
Winform
go
设计模式
PHP
python
nginx
网络安全
文艺范
mac
Search
标签搜索
php
typecho
代码注释
mysql
redis
nginx
golang
docker
html
curl
linux
go
thinkphp
mamp
laravel
跨域
http
rsa
sql
酒
依然范儿特西
累计撰写
122
篇文章
累计收到
26
条评论
首页
栏目
默认分类
typecho
代码改变世界
mysql
Winform
go
设计模式
PHP
python
nginx
网络安全
文艺范
mac
页面
留言板
友情链接
搜索到
1
篇与
sql
的结果
2021-06-07
【Sql】mysql whereIn根据查询id排序
mysql in根据查询id排序mysql in根据查询时,返回结果是自行排序的,如果要按照我们查询的ID进行排序, 要用到order by field,下面用几个例子来说明一下mysql in查询排序SQL:select * from laofan_table where id IN (3,6,9,1,2,5,8,7);这样的情况取出来后,其实,id还是按1,2,3,4,5,6,7,8,9,排序的, 但如果我们真要按IN里面的顺序排序怎么办?我们可以用order by fieldSQL: select * from laofan_table where id IN (3,6,9,1,2,5,8,7) order by field(id,3,6,9,1,2,5,8,7);查询出来的结果就是按自定义的ID进行排序了.orm 用法$ret = Db::table('laofan') ->field('*') ->whereIn('id',$ids) ->order('id',$ids) ->select() ->toArray();
2021年06月07日
181 阅读
0 评论
0 点赞