使用 MySQL 从表中删除重复数据
我正在尝试从数据库中删除重复的数据。我发现这里有一个很好的示例,说明如何在 Oracle 数据库上执行此操作。
该答案中的底部查询(仅选择重复的行)在 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
I am trying to remove duplicate data from my database. I found a nice example on here of how to do this on an oracle database.
The bottom query from that answer (only selecting the duplicate rows) works in MySQL, but the delete query (see below) does not...
"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
)"
The error I get is:
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
So, I had a look for the right delete syntax and any syntax to use, but couldn't find anything wrong with my query... Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这个查询 -
Try this query -
AS
运算符不适用于 MySQL 中的DELETE
语句。试试这个(未验证):
The
AS
operator doesn't work withDELETE
statements in MySQL.Try this (unverified):