日期:2014-05-17 浏览次数:20560 次
create table a(AId int,AName varchar(10))
insert into a
select 1, 'aa' union all
select 2, 'bb' union all
select 3, 'cc'
create table B(BId int,BName varchar(10))
insert into b
select 1 ,'aa' union all
select 2 ,'bb' union all
select 3 ,'cc'
create table C(AId int,BId int)
insert into c
select 1,1 union all
select 1,2
select *
from
(
select *
from a
where a.aid = 1
)a
cross join
(
select b.*
from b
where b.bid not in (select bid from c where aid = 1)
)b
/*
AId AName BId BName
1 aa 3 cc
*/