今天突然发现一个貌似相仿的例子,在此记录。
select lxdh,kh,zhkhmc,khrzjhm from table
where id = 666 and lxdh is not null
and lxdh in
(select lxdh from table where id = 666
and lxdh is not null and khrzjhm is not null
group by lxdh
having count(distinct khrzjhm)>=2)
本文记录了一个复杂的SQL查询案例,该查询旨在从特定ID的数据中筛选出符合条件的联系人及其相关信息。通过子查询与多条件结合的方式,实现了对指定ID下联系人信息的精确检索,并确保了每位联系人至少关联两个不同的证件号码。
今天突然发现一个貌似相仿的例子,在此记录。
select lxdh,kh,zhkhmc,khrzjhm from table
where id = 666 and lxdh is not null
and lxdh in
(select lxdh from table where id = 666
and lxdh is not null and khrzjhm is not null
group by lxdh
having count(distinct khrzjhm)>=2)

被折叠的 条评论
为什么被折叠?