现在有两个关系R(A,B,C)和S(B,C,D)
我想问一下R÷S的SQL语句怎么写呀?

解决方案 »

  1.   

    现在有两个关系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]
      

  2.   

    不是减,是除
        [align=center]====  ====
    [/align]
      

  3.   


    我一直认为是减
    减和除是不一样的。
    减比较简单,一次not exist 就搞定了,不需要 not in 了。估计是你没看清。
        [align=center]====  ====
    [/align]
      

  4.   

    怎么我用了你的不行呀,检测一下你的代码好吗? 你是在mySQL 还是在Oracle中试的?
        [align=center]====  ====
    [/align]
      

  5.   

    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]
      

  6.   

    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]
      

  7.   

    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));