I have a problem, actually a question on how would be the easiest way to delete all the duplicates in a MySQL table based on the first SELECT's name and timestamp.
So, I have this table:
SELECT * FROM search;
+------+--------+------------+--------------------------+-----------------------+
| id | uid | string | cat | timestamp |
+------+--------+------------+--------------------------+-----------------------+
|39523 | 87 |eat to live | a:1:{i:0;s:5:"toate";} | 2013-10-07 17:01:41 |
|39524 | 87 |eat to live | s:6:"author"; | 2013-10-07 17:01:41 |
|39525 | 87 |eat to live | s:6:"people"; | 2013-10-07 17:01:41 |
|39526 | 87 |eat to live | s:7:"company"; | 2013-10-07 17:01:41 |
|39527 | 87 |eat to live | s:6:"author"; | 2013-10-07 17:01:42 |
|39532 | 31 | friends | a:1:{i:0;s:5:"toate";} | 2013-10-07 17:04:17 |
|39533 | 31 | friends | s:6:"people"; | 2013-10-07 17:04:17 |
|39534 | 31 | friends | s:7:"company"; | 2013-10-07 17:04:17 |
|39535 | 31 | friends | s:6:"author"; | 2013-10-07 17:04:17 |
+------+--------+------------+--------------------------+-----------------------+
And I want to have left only the first unique appearance. My solution would be to Select all the rows, go through' them, and for each Row to delete all the rows that match the same string, the same uid and timestamp to be either the same timestamp or +1 second.
Any thoughts / suggestions ? I can do this in PHP and was wondering if there is an easier way to do this directly with an SQL query.
Thanks