有AB两表,A表主码为c_id,B表外码p_c_id参照c_id,查询c_id,条件是没有p_c_id与之相等
方式1:
select
c_id
from A a
left join B b
on a.c_id = b.p_c_id
where b.p_c_id is null;
方式2:
select c_id from A where c_id not in
(select p_c_id from B);
select c_id from A where c_id not in
(select p_c_id from B);
或者
select c_id from A,B where c_id != p_c_id;