1
這應該是一件非常簡單的事情,但我對(My)SQL很陌生。MySQL:刪除其ID不在其他查詢的結果集中的記錄
基本上,給予customers
表屬性id, client, etc.
,其中client
場不一定是唯一的,我要排除行,其中client
場是前值的副本。
以下:
SELECT MIN(id) FROM customers GROUP BY client
返回我想要的行的唯一ID的。我想要一切。
我試圖
DELETE FROM customers WHERE customer.id NOT IN
(SELECT MAX(id) FROM customers GROUP BY client)
無濟於事。 (ERROR 1093 (HY000): You can't specify target table 'customers' for update in FROM clause
)。
爲什麼它不起作用,我需要做些什麼來完成我的目標?
謝謝。