1. 找出没有购买红色零件的工程的工程号。
select JNO from SPJ where PNO not in (select PNO from P where COLOR='RED')2. 找出购买所有红色零件的工程的工程号。select JNO from SPJ where PNO in (select PNO from P where COLOR='RED')

解决方案 »

  1.   

    1.
    select jno from j where (select jno from spj where pno in (select pno from p where color='red'))
      

  2.   

    1. 找出没有购买红色零件的工程的工程号。
    select JNO from SPJ where PNO not in (select PNO from P where COLOR='RED')2. 找出购买所有红色零件的工程的工程号。select JNO from SPJ where PNO in (select PNO from P where COLOR='RED')
      

  3.   

    1. 找出没有购买红色零件的工程的工程号。
    select sno from j inner join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color<>'红色')2. 找出购买所有红色零件的工程的工程号。
    select sno from j inner join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color='红色')
      

  4.   

    1. 找出没有购买红色零件的工程的工程号。
    select sno from j inner join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color<>'红色')2. 找出购买所有红色零件的工程的工程号。
    select sno from j inner join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color='红色')
      

  5.   

    1. 找出没有购买红色零件的工程的工程号。
    select sno from j inner join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color<>'红色')2. 找出购买所有红色零件的工程的工程号。
    select sno from j inner join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color='红色')
      

  6.   

    1 select sno from j join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color<>'红色')2 select sno from j join spj on j.jno=spj.jno
    where spj.pno in(select pno from p where color='红色')
      

  7.   

    1,select spj.pno from spj inner join P on spj.pno=p.pno
    where p.color<>'red'2,1,select spj.pno from spj inner join P on spj.pno=p.pno
    where p.color='red'
      

  8.   

    1. 找出没有购买红色零件的工程的工程号。
    select JNO from J where JNO not in 
    (select JNO from SPJ A left join P on A.PNO = P.PNO where P.COLOR = '红色')
      

  9.   

    2. 找出购买所有红色零件的工程的工程号。
    select JNO from SPJ A where not exists 
    (select PNO from P where P.COLOR = '红色' and PNO not in (select PNO from SPJ where JNO = A.JNO))