1

我必须表 t1 和 t2。我想要

删除 t1 中的记录,其中

t1.c1 = t2.c1 AND t1.c2 = t2.c2 AND t1.c3 = t2.c3 AND t2.c4 = "某事"

我以为我可以做类似的事情:

delete
FROM table1 t1
INNER JOIN table2 t2
 on 
 (t1.c1 = t2.c1 
  AND t1.c2 = t2.c2 
  AND t1.c3 = t2.c3)
 where t2.c4 = 'something'

但是,在这样做之前,我正在尝试做

select *
FROM table1 t1
INNER JOIN table2 t2
 on 
 (t1.c1 = t2.c1 
  AND t1.c2 = t2.c2 
  AND t1.c3 = t2.c3)
 where t2.c4 = 'something' 

它没有返回我要删除的记录。

有关如何修复此查询的任何提示?(在甲骨文中工作)

4

2 回答 2

2

DELETE你很接近了!,只需在关键字后添加要删除的表名

DELETE  t1   -- <<==== HERE
FROM    table1 t1
        INNER JOIN table2 t2
            ON  t1.c1 = t2.c1 AND 
                t1.c2 = t2.c2 AND 
                t1.c3 = t2.c3
 WHERE  t2.c4 = 'something'
于 2013-03-07T16:49:29.213 回答
0

我得到了它!!

 DELETE  
    FROM    table1 t1
    WHERE EXISTS
      SELECT * 
      from table2 t2
      where  t1.c1 = t2.c1 AND 
            t1.c2 = t2.c2 AND 
            t1.c3 = t2.c3 AND
            t2.c4 = 'something'
于 2013-03-07T19:45:00.613 回答