1

i have a table with some duplicate values and i want to remove them:

table1:

id | access | num 12 1144712030 101 13 1144712030 101 14 1154512035 102 15 1154512035 102 

i would like to remove the duplicates so i will have left:

id | access | num 12 1144712030 101 14 1154512035 102 

any idea how to do this in a mysql command?

thanks

1

3 Answers 3

2

The simpler solution i think would be:

CREATE TABLE new_table as SELECT id,DISTINCT access,num FROM original_table TRUNCATE TABLE original_table INSERT INTO original_table SELECT * FROM new_table DROP TABLE new_table; 

Note:

I think some kind of cursor could be used, and maybe a temporary table. But you should be really careful.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, i messed it up with new/old. I Changed the names now.
1

if your table called foo, rename in foo_old, re-create table foo as a structure identical to foo_old. Make a query with the DISTINCT operator obtained and the results reported on Table foo_old enter them in foo.

Comments

0

do a quick search here for DELETE DUPLICATE ROWS

you'll find a ton of examples.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.