Mysql的in和not in的用法

1. not in的结果集中出现null则查询结果为null;

select * from device where code not in ('A', 'B', null);

 上面查询结果为 null,查不出想要的结果

 

2、in的结果集中出现null不影响;

select * from device where code in ('A', 'B', null);

不影响,可查询出想要的结果

 

posted @ 2022-06-13 17:03  唏嘘-  阅读(274)  评论(0编辑  收藏  举报