【问题标题】:How can I delete record from table in Oracle?如何从Oracle中的表中删除记录?
【发布时间】:2013-11-17 12:48:35
【问题描述】:

我有三张桌子

表 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'and 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

【问题讨论】:

  • 再读一遍你的第三行
  • 这是 Oracle,从 ORA-.... 错误消息来看,NOT 用于(Microsoft)SQL Server - 相应地更新了标签跨度>

标签: oracle join


【解决方案1】:

试试这个:

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

【讨论】:

    【解决方案2】:
    3  and pno in (select pno from parts where color='red')
    

    【讨论】:

      【解决方案3】:
       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)
      

      【讨论】:

        【解决方案4】:
         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)

        【讨论】:

          猜你喜欢
          • 2019-11-25
          • 2015-09-27
          • 1970-01-01
          • 2017-11-09
          • 2011-04-28
          • 1970-01-01
          • 2011-12-19
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多