List:General Discussion« Previous MessageNext Message »
From:Don Read Date:April 13 1999 4:58am
Subject:Re: delete duplicate
View as plain text  
At 09:35 PM 4/12/99 -0700, Xah Lee wrote:
>Suppose I have a table that has identical rows for some reason. I need to 
>delete the duplicates. Can this be done in MySql's SQL?
>

mysql> select * from atable;
+------+-------+
| num  | name  |
+------+-------+
|    1 | one   |
|    2 | two   |
|    3 | three |
|    1 | one   |
+------+-------+
4 rows in set (0.00 sec)

mysql> create table x_t (num int,name varchar(16));   

mysql> insert into x_t
    -> select distinct * from atable;
Query OK, 3 rows affected (0.14 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from x_t;
+------+-------+
| num  | name  |
+------+-------+
|    1 | one   |
|    2 | two   |
|    3 | three |
+------+-------+
3 rows in set (0.01 sec)

Regards,

-- 
Don Read                               sysop@stripped
EDP Manager                                dread@stripped
Calcasieu Lumber Co.                             Austin TX
- The problem with people who have no vices is that you can be
      pretty sure they're going to have some pretty annoying virtues.
Thread
delete duplicateXah Lee13 Apr
Re: delete duplicateDon Read13 Apr
Re: delete duplicateGerald Clark13 Apr
Re: delete duplicateJeff Hill13 Apr
Re: delete duplicateGerald Clark16 Apr