List:General Discussion« Previous MessageNext Message »
From:gerald_clark Date:October 8 2004 1:26pm
Subject:Re: Delete duplicate entry
View as plain text  

Daniel Kasak wrote:

> gerald_clark wrote:
>> Batara Kesuma wrote:
>>> Hi,
>>> I have a table that looks like:
>>> CREATE TABLE `message_inbox` (
>>>  `member_id` mediumint(8) unsigned NOT NULL default '0',
>>>  `message_id` int(10) unsigned NOT NULL default '0',
>>>  `new` enum('y','n','replied') NOT NULL default 'y',
>>>  `datetime` datetime default NULL,
>>>  KEY `idx_1` (`member_id`,`new`),
>>>  KEY `idx_2` (`member_id`,`datetime`)
>>> ) TYPE=InnoDB
>>> Now, I want to add a primary key to it.
>>> ALTER TABLE message_inbox ADD PRIMARY KEY (member_id, message_id)
>>> But there are already some duplicated entries. ERROR 1062: Duplicate 
>>> entry '10244-80871' for key 1
>>> How can I tell MySQL to delete the duplicated entry and continue to 
>>> make primary key? Is there any efficient way to do this? Thank you 
>>> very much.
> That hardly seems like a solution. If the above works, then I'd call 
> that 'feature' a bug. 

What an odd statement.
The ignore option is there to allow you to create a unique index, 
discarding duplicates.
Since it does exactly what was asked for, why doesn't it seem like a 
Why is something that does what it was designed to do a bug?

Delete duplicate entryBatara Kesuma7 Oct
  • Re: Delete duplicate entrygerald_clark7 Oct
    • Re: Delete duplicate entryDaniel Kasak8 Oct
      • Re: Delete duplicate entryEldo Skaria8 Oct
        • Re: Delete duplicate entryDaniel Kasak8 Oct
    • Re: Delete duplicate entryBatara Kesuma12 Oct
  • Re: Delete duplicate entrygerald_clark8 Oct