情况是这样的:
我有100个学生,我写了两个sql。
分别是:
1. 查询报名参赛的人有多少。
2. 查询没有报名参赛的人有多少。
但是两个查询结果如下:
1. 60
2. 0
这是为什么呢?
是因为,我存储报名数据时,有个用户ID存储为null。
即 我的第二个查询:
select count(id) from users where id not in (select user_id from game_user);
中 select user_id from game_user
的结果集中,包含了null。
就导致,外查询的结果集为空了。
mysql异常-not in查询结果为空
最新推荐文章于 2024-05-10 09:57:40 发布