EDIT
This query is not working, any idea why?
select `key`, distinct `filename`, `url`, `processed`, `timestamp` from snaps;
It says to check syntax near 'distinct
filename``
I have the following table
CREATE TABLE IF NOT EXISTS `snaps` (
`filename` varchar(255) COLLATE utf8_bin NOT NULL,
`url` text COLLATE utf8_bin NOT NULL,
`processed` int(11) NOT NULL,
开发者_开发问答 `timestamp` int(11) NOT NULL,
KEY `key` (`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
I exported the rows of the table and mistakenly imported it back into the same table. So now I have two rows of everything. filename
is unique.
How can I delete the duplicate records?
SELECT DISTINCT into a temporary table, flush the first one, and move them back again.
If you have all the original unduplicated rows of the table, can you not just
TRUNCATE <table>
and then reimport them?
Does second set of rows has an identical timestamp from the insert? If so, you could DELETE based on that timestamp.
Alternately, you could SELECT INTO OUTFILE
, delete the last half, TRUNCATE TABLE
and then LOAD DATA INFILE
.
精彩评论