似乎並不重複,因爲這個問題是不同的。MySQL中刪除重複行的最佳方式是除ID以外的所有行?
我的表格有3列:id,col2,col3。我用這個方法來刪除重複的行:
create table temp_table as
select * from my_table where 1 group by col2,col3;
drop table my_table;
rename table temp_table to my_table;
然而,實際上MY_TABLE有很多列,不只是3,痛苦地在查詢中列出。所以我想問問是否有一種方法可以做這樣的查詢:
create table temp_table as
select * from my_table where 1 group by * except id;
drop table my_table;
rename table temp_table to my_table;
有沒有可能的方法?
你可以建立列的列表與[查詢](http://dev.mysql.com/doc/refman/5.0/en/show-columns.html)和PHP,並使用一個變量將它插入到'SELECT'中。 –
這可能是一種方式 – jondinham
*也許*你可以做一個[''GROUP_CONCAT()'](http://dev.mysql.com/doc/refman/5.5/en/group-by-functions.html#function_group- concat)在一個子選擇''上。不過不確定。這真是一個猜測。 –