我想從我的數據庫中刪除重複的數據。我發現a nice example on here of how to do this on an oracle database。使用MySQL刪除表中的重複數據
從答案(只選擇重複行)的作品在MySQL,但刪除查詢(見下文)不會在底部查詢...
"DELETE FROM studios as a
WHERE a.id >
ANY (SELECT b.id
FROM studios as b
WHERE a.name = b.name
AND a.email = b.email
)"
我得到的錯誤是:
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 'a
WHERE a.id >
ANY (SELECT b.id
FROM studios as b
' at line 1
所以,我看了一下delete syntax和any syntax的使用權限,但找不到任何錯誤的查詢...任何想法?
MySQL不喜歡這裏的'AS'operator。但我不知道如何解決這個問題,而不會出現鋸齒。 – 2012-02-01 09:10:41
我對「ANY」語法不太確定,但是您是否嘗試過使用「IN」語句。例如WHERE a.id IN(SELECT b.id ... – Robert 2012-02-01 09:15:36