这有效

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

最佳答案

尝试:

UPDATE productinfo a SET Deleted = '1'
    WHERE NOT EXISTS(SELECT NULL
                    FROM productinfo_temp b
                                WHERE a.ProductID = b.ProductID)

关于mysql - sql更新不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14207324/

10-12 18:33