Deleting Duplicates in MySQL

Posted by elmaso on Stack Overflow See other posts from Stack Overflow or by elmaso
Published on 2010-04-18T01:12:54Z Indexed on 2010/04/18 1:23 UTC
Read the original article Hit count: 297

Filed under:
|
|

Query was this:

CREATE TABLE `query` (
`id` int(11) NOT NULL auto_increment,
`searchquery` varchar(255) NOT NULL default '',
`datetime` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM

first I want to drop the table with:

ALTER TABLE `querynew` DROP `id`

and then delete the double entries.. I tried it with:

INSERT INTO `querynew` SELECT DISTINCT * FROM `query`

but with no success.. :(

and with ALTER TABLE query ADD UNIQUE ( searchquery ) - is it possible to save the queries only one time?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about insert