MySQL中 You can’t specify target table for update in FROM clause 错误解决方法
UPDATE t_comment SET pid=0 #SELECT * FROM t_comment #同时选择并且更新,MySQL需要中间表进行过滤 WHERE id IN( SELECT a.id FROM ( SELECT cb.id FROM t_comment AS cb GROUP BY article_id HAVING COUNT(*)=1 ) AS a )
需要使用中间表进行过滤,示例SQL语句如上。