Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试删除 mysql 5.1 表中的重复行
查询是
delete from sessions o where exists (select * from sessions i where i.data=o.data and i.id<>o.id);
但它似乎不起作用,我读到在 mysql 中使用表别名来删除语句是不可能的,但是这是如何工作的:删除记录?
试试这个查询 -
DELETE t1 FROM sessions t1 JOIN (SELECT data, MIN(id) id FROM sessions GROUP BY data) t2 ON t1.id <> t2.id AND t1.data = t2.data;