Removing Duplicates of a Particular Row
mysql>
mysql> CREATE TABLE t
-> (
-> color CHAR(10)
-> )
-> ;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> INSERT INTO t(color)
-> VALUES('blue'),('green'),('indigo'),('orange'),('red'),('violet'),('yellow')
-> ;
Query OK, 7 rows affected (0.00 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql>
mysql> SELECT name FROM color;
+--------+
| name |
+--------+
| blue |
| green |
| indigo |
| orange |
| red |
| violet |
| yellow |
+--------+
7 rows in set (0.00 sec)
mysql>
mysql>
mysql> DELETE FROM t WHERE color = 'blue' LIMIT 2;
Query OK, 1 row affected (0.00 sec)
mysql> DELETE FROM t WHERE color = 'green' LIMIT 1;
Query OK, 1 row affected (0.00 sec)
mysql> DELETE FROM t WHERE color = 'red' LIMIT 1;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM t;
+--------+
| color |
+--------+
| indigo |
| orange |
| violet |
| yellow |
+--------+
4 rows in set (0.00 sec)
mysql>
mysql> drop table t;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category