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语句如上。
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语句如上。
转载于:https://www.cnblogs.com/Wcy100/p/5754910.html