除:
create table #1(A char(1),B char(1),C char(1),D char(1))
insert #1 values('a','b','c','d')
insert #1 values('a','b','e','f')
insert #1 values('b','c','e','f')
insert #1 values('e','d','c','d')
insert #1 values('e','d','e','f')
insert #1 values('a','b','d','e')create table #2 (A char(1),B char(1))
insert #2 values('c','d')
insert #2 values('e','f')select a,b from #1 bb where exists(select 1 from (select distinct #1.a,#1.b,#2.a c,#2.b d from #1,#2) aa where aa.a=bb.a and aa.b=bb.b and aa.c=bb.c and aa.d=bb.d) group by a,b having count(*)>1
drop table #1
drop table #2
create table #1(A char(1),B char(1),C char(1),D char(1))
insert #1 values('a','b','c','d')
insert #1 values('a','b','e','f')
insert #1 values('b','c','e','f')
insert #1 values('e','d','c','d')
insert #1 values('e','d','e','f')
insert #1 values('a','b','d','e')create table #2 (A char(1),B char(1))
insert #2 values('c','d')
insert #2 values('e','f')select a,b from #1 bb where exists(select 1 from (select distinct #1.a,#1.b,#2.a c,#2.b d from #1,#2) aa where aa.a=bb.a and aa.b=bb.b and aa.c=bb.c and aa.d=bb.d) group by a,b having count(*)>1
drop table #1
drop table #2
不是要用SQL写出来
只是用纯理论的帮我解释一下,谢谢
求出的结果必须在关系R里与关系S所有的记录要有组合如:
关系R应为有:
a b c d
a b e f
所以a b要被查询出
应为有
e d c d
e d e f
所以e d要被查询出
应为只有
b c e f
没有b c 和c d的组合所以没有b c