如题
删除多条数据库的话 一般where id=1 or id=2 or id=3......
然而删除id是用一个数组装的 我的做法是遍历来删除
请问有没有简单点的方法 就是不遍历删除?
还有in 包含 、 not in 不包含、between 在范围 、 not between 不在范围
这四个是什么意思?
如题
删除多条数据库的话 一般where id=1 or id=2 or id=3......
然而删除id是用一个数组装的 我的做法是遍历来删除
请问有没有简单点的方法 就是不遍历删除?
还有in 包含 、 not in 不包含、between 在范围 、 not between 不在范围
这四个是什么意思?
in(1,2,3,4) ,就是这括号里边的全部符合
not in (5,6,7,8),就是括号里边的全部不符合
between 9 and 12 ,就是9-12(9,10,11,12)这个范围内全部符合
not between 12 and 15 ,就是12-15(12,13,14,15)这个范围内全部不符合
最简单的,自己写一遍看看结果就知道了。
你这个删除多条,既然是封装成数组,就转成逗号分隔的字符串放到 in 里就可以了
立即学习“PHP免费学习笔记(深入)”;
delete from 表 where id in(1,2,3) #id为1,2,3的
delete from 表 where id not in(1,2,3) #除1,2,3之外的所有记录
delete from 表 where id between 1 and 5 #id为1-3的
delete from 表 where id not between 1 and 5 #除1-5之外的所有记录
delete from table where id in (1,2,3))
把你的数组转成“1,2,3”字符串
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号