这有效
SELECT * FROM productinfo a
WHERE NOT EXISTS(SELECT NULL
FROM productinfo_temp b
WHERE a.ProductID = b.ProductID)
但是,它希望从该结果更新productinfo表
UPDATE a SET Deleted = '1' FROM productinfo a
WHERE NOT EXISTS(SELECT NULL
FROM productinfo_temp b
WHERE a.ProductID = b.ProductID)
但它不起作用。 UPDATE有什么问题? 这是错误
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM productinfo a WHERE NOT EXISTS(SELECT NULL FROM productinfo' at line 1
答案 0 :(得分:2)
尝试:
UPDATE productinfo a SET Deleted = '1'
WHERE NOT EXISTS(SELECT NULL
FROM productinfo_temp b
WHERE a.ProductID = b.ProductID)
答案 1 :(得分:2)
<击> 撞击>
<击>删除FROM
条款。
UPDATE productinfo a
SET Deleted = '1'
WHERE NOT EXISTS(SELECT NULL
FROM productinfo_temp b
WHERE a.ProductID = b.ProductID)
击> <击> 撞击>
或只是使用LEFT JOIN
UPDATE productinfo a
LEFT JOIN productinfo_temp b
ON a.ProductID = b.ProductID
SET a.Deleted = 1
WHERE b.ProductID IS NULL
答案 2 :(得分:1)
我也进来了!
UPDATE a SET Deleted = '1'
WHERE NOT EXISTS(SELECT NULL
FROM productinfo_temp b
WHERE a.ProductID = b.ProductID)