mysql 查询 not in not like和in like啥区别啊select * from aaaa where id in(1,2,3);select * from aaaa where id not in(1,2,3);select * from aaaa where tt like "%as%";select * from aaaa where tt not like "%as%";1 3我懂 2 4这个加了not是什么意思啊
问题描述:
mysql 查询 not in not like和in like啥区别啊
select * from aaaa where id in(1,2,3);
select * from aaaa where id not in(1,2,3);
select * from aaaa where tt like "%as%";
select * from aaaa where tt not like "%as%";
1 3我懂 2 4这个加了not是什么意思啊
答
加了not就是in的补集.
select * from aaaa where id in(1,2,3); --查找id在1,2,3中的数据集
select * from aaaa where id not in(1,2,3); --查找id不在1,2,3中的数据集
select * from aaaa where tt like "%as%"; --查找tt字段中包含as字符的数据集
select * from aaaa where tt not like "%as%"; --查找tt字段中不包含as字符的数据集