现在有两个关系R(A,B,C)和S(B,C,D) 我想问一下R÷S的SQL语句怎么写呀? 如果是ORACLE中 select from R as x where not exist (select * from S where (B,C) not in (select B,C from R where R.A=x.A)); [align=center]====思想重于技巧==== [/align]
mySQLselect distinct A from R as x where not exists ( select * from S where not exists (select * from R where A=x.A and B=S.B and C=S.C) ); [align=center]====思想重于技巧==== [/align]
我想问一下R÷S的SQL语句怎么写呀? 如果是ORACLE中
select
from R as x
where not exist (select * from S where (B,C) not in (select B,C from R where R.A=x.A)); [align=center]==== 思想重于技巧 ====
[/align]
[align=center]==== 思想重于技巧 ====
[/align]
我一直认为是减 减和除是不一样的。
减比较简单,一次not exist 就搞定了,不需要 not in 了。估计是你没看清。
[align=center]==== 思想重于技巧 ====
[/align]
[align=center]==== 思想重于技巧 ====
[/align]
from R as x
where not exist (select * from S where (B,C) not in (select B,C from R where R.A=x.A));
[align=center]==== 思想重于技巧 ====
[/align]
from R as x
where not exists
(
select * from S
where not exists
(select * from R where A=x.A and B=S.B and C=S.C)
);
[align=center]==== 思想重于技巧 ====
[/align]
where not exist (select * from S where (B,C) not in (select B,C from R where R.A=x.A));