开发者

How do I workaround this error ? You can't specify target table my table for update in FROM clause

I'm struggling to convert my select query into a update query, it has aliases..

Update pads set RemoveMeDate = '1999-01-01 00:00:00' where padid in (
SELECT old_table.padid
FROM `jules-fix-reasons`.`pads` AS old_table
JOIN `jules`.`pads` AS new_table ON old_table.padid = new_table.`PadID`
WHERE new_table.RemoveMeDate <> '2001-01-01 00:00:00'
AND old_table.RemoveMeDate = '2001-01-01 00:00:00')

I've tried remov开发者_运维技巧ing the aliases, but that doesn't help :(

EDIT - Richard, screen shot

How do I workaround this error ? You can't specify target table my table for update in FROM clause


Update pads 
set RemoveMeDate = '1999-01-01 00:00:00' 
where padid in (SELECT padid FROM 
                ( SELECT old_table.padid 
                 FROM `jules-fix-reasons`.`pads` AS old_table JOIN 
                      `jules`.`pads` AS new_table ON old_table.padid = new_table.PadID
                 WHERE new_table.RemoveMeDate <> '2001-01-01 00:00:00' AND old_table.RemoveMeDate = '2001-01-01 00:00:00') a)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜