select xs_id, name from xs where not exist(
select * from kc where not exist(
select * from xs_kc where xs_ck.xs_id =xs.xs_id and xs_kc.kc_id=kc.kc_id
)
)
问 这句查询的是什么结果
select * from kc where not exist(
select * from xs_kc where xs_ck.xs_id =xs.xs_id and xs_kc.kc_id=kc.kc_id
)
)
问 这句查询的是什么结果
from xs
where xs.xs_id not in
(select kc.id from kc, xs_kc where xs_kc.kc_id = kc.kc_id)
---------- --------------------
1 jerry
2 jack
3 frankSQL> select * from kc; KC_ID NAME
---------- --------------------
2 clack
5 jamesSQL> select * from xs_kc; KC_ID XS_ID
---------- ----------
2 2SQL> select xs_id, name from xs where not exists(
2 select * from kc where not exists(
3 select * from xs_kc where xs_kc.xs_id =xs.xs_id and xs_kc.kc_id=kc.kc
_id
4 )
5 ) ;未选定行SQL> select xs_id, name from xs where exists(
2 select * from kc where not exists(
3 select * from xs_kc where xs_kc.xs_id =xs.xs_id and xs_kc.kc_id=kc.kc
_id
4 )
5 ) ; XS_ID NAME
---------- --------------------
1 jerry
2 jack
3 frankSQL>
from xs
where not exist(
select *
from kc
where not exist(
select *
from xs_kc
where xs_ck.xs_id =xs.xs_id --这个条件跨多个子查询,不能认识到XS表。
and xs_kc.kc_id=kc.kc_id
)
)
结果应该是选择了所有课程的学生id和name