Duplicate entry

Hi Guys,

Got a table like the below

[code]CREATE TABLE IF NOT EXISTS group (
user_id varchar(50) DEFAULT NULL,
id bigint(255) NOT NULL,
number varchar(15) DEFAULT NULL,
group varchar(500) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


[/code]

I want that if there is duplicate entry with the same user_id & number & group it’s removed.

what would the best way to do this with the table?

best way, instead of removing the dupes, is preventing them from happening –

ALTER TABLE `group` ADD UNIQUE INDEX ( user_id, `number`, `group` )
by the way, GROUP is a reserved word, i suggest you rename the table as well as the column

aslo NUMBER probably

Nice one I will do that now :smile:
Thanks for your help again :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.