我想了解为什么查询
select distinct m.id, m.sex
from member m
join household h on m.household_id = h.id
join contact c on c.household_id = h.id
where c.contact_date between '2018-04-01' and '2018-04-30';
返回 923 行,但将通过查询返回值 918
select count(distinct m.id, m.sex)
from member m
join household h on m.household_id = h.id
join contact c on c.household_id = h.id
where c.contact_date between '2018-04-01' and '2018-04-30';
查询
select count(distinct m.id)
from member m
join household h on m.household_id = h.id
join contact c on c.household_id = h.id
where c.contact_date between '2018-04-01' and '2018-04-30';
也返回 923。
该语句select * from member m where sex not in ('Male', 'Female')
不返回任何行。
m.sex is null
我想你有 5 条记录。应用于 NULL 的任何运算符(除了
IS [NOT] NULL
和<=>
)返回 NULL 被视为 False。