Rumah > Soal Jawab > teks badan
语句:
DELETE FROM price_monitor WHERE EXISTS (SELECT 1 FROM price_monitor b WHERE b.domain = price_monitor.domain );
报错:
#1093 - You can't specify target table 'price_monitor' for update in FROM clause
该如何解决呢?
三叔2016-11-08 09:40:51
DELETE FROM price_monitor WHERE id NOT IN ( SELECT * FROM ( SELECT MAX(id) FROM price_monitor GROUP BY domain ) as tmp )
根据你的表字段替换上面的id。 如果要保留id最小的数据, 就把MAX(ID)改成MIN(id)