DB2内部连接删除

时间:2014-05-28 08:09:30

标签: sql db2 inner-join sql-delete

我有这样的查询:

DELETE FROM db2inst1.REPORTER_STATUS INNER JOIN REPORTER_DETAILS 
ON REPORTER_STATUS.SERVERSERIAL = REPORTER_DETAILS.SERVERSERIAL 
AND year(REPORTER_STATUS.FIRSTOCCURRENCE)=2011 AND 
month(REPORTER_STATUS.FIRSTOCCURRENCE)=12 AND 
day(REPORTER_STATUS.FIRSTOCCURRENCE)=12

我想运行像tihs这样的查询,但它给了我错误。我该如何运行这样的查询?

1 个答案:

答案 0 :(得分:2)

不确定在DB2中是否允许使用已发布的删除形式(DELETEJOINS),但您可以尝试执行以下操作

DELETE FROM REPORTER_STATUS 
WHERE year(REPORTER_STATUS.FIRSTOCCURRENCE)=2011 
AND month(REPORTER_STATUS.FIRSTOCCURRENCE)=12 
AND day(REPORTER_STATUS.FIRSTOCCURRENCE)=12
AND SERVERSERIAL in 
(
SELECT distinct SERVERSERIAL from REPORTER_DETAILS
)