如何从Oracle中的表中删除记录?

时间:2013-11-17 12:48:36

标签: oracle join

我有三张桌子

表1 供应商sno, sname, city

1, ahmad, jeddah

表2 部分pno, pname, color

1, laptop, red

表3 supplier_parts_shipment shno, sno, pno, date

1, 1, 1, 2014

我需要删除city ='jeddah'和color ='red'的货件 - 怎么做?

  1  delete from supplier_parts_shipment
  2  where sno in (select sno from supplier where city='jeddah')
  3  and pno(select pno from parts where color='red')
  4* and (sno=sno) and (pno=pno)
SQL> /
and pno(select pno from parts where color='red')
        *
ERROR at line 3:
ORA-00936: missing expression

4 个答案:

答案 0 :(得分:0)

3  and pno in (select pno from parts where color='red')

答案 1 :(得分:0)

 delete from supplier_parts_shipment as A
 where A.sno in 
 (select B.sno from supplier as B, supplier_parts_shipment  as C, parts as D
  where B.city='jeddah' and D.color='red' and C.sno=B.sno and C.pno=D.pno)

答案 2 :(得分:0)

 delete sps from supplier_parts_shipment as sps
 join supplier as sup on sps.sno = sup.sno
 join  parts as prt on sps.pno = prt.pno
 where sup.city = 'jeddah' AND prt.color = 'red'

并且在第3行中缺少您的查询

和pno in(从color ='red'的部分选择pno)

答案 3 :(得分:0)

试试这个:

delete from supplier_parts_shipment
where sno in (select sno from supplier where city='jeddah')
and pno in (select pno from parts where color='red');