问题描述
我在mysql表(my_sale_time
)中的列类型为timestamp
....影响行值看起来像这样
I have column in mysql table (my_sale_time
) of type timestamp
....infact the rows value look like this
2010-12-01 14:38:07
2010-12-01 17:14:18
...
所以我需要mysql查询删除那些在表中多次重复的日期的值....正如我在示例sale_time_value
...... only date 中提到的那样值相同,但时间不同....所以我要获取所有行,将日期重复多次,并删除重复的日期
so what i need mysql query to delete those value whose date is repeated multiple times in table.....as i mentioned in sample sale_time_value
.....only date is repeated with same value but time is different....so i want to get all rows, date is repeated multiple times and delete duplicate dates
推荐答案
删除重复行的基本原理:
The basic principle of deleting duplicate rows:
CREATE TEMPORARY TABLE tmptbl AS SELECT DISTINCT * FROM my_sale_time;
DELETE FROM my_sale_time;
INSERT INTO my_sale_time SELECT * FROM tmptbl;
您可能必须指定列和WHERE子句(我不太了解您的条件).当然,您应该在开发服务器上对其进行测试运行,并且不要忘记将其作为具有锁定表的单个事务来运行.
You may have to specify columns and WHERE clauses (I didn't really understand your criteria).And of course you should test-run it on a development server and don't forget to run it as a single transaction with locked tables.
这篇关于如何删除mysql表中的重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!