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-
If you have an auto_increment field, use this:
DELETE FROM
`mytable`
WHERE
`my_auto_increment_field` NOT IN (
SELECT
MAX(`my_auto_increment_field`)
GROUP BY
`my_sale_time`
);
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;
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.