Home >Database >Mysql Tutorial >How to remove duplicate values ​​stored in reverse order from MySQL table?

How to remove duplicate values ​​stored in reverse order from MySQL table?

PHPz
PHPzforward
2023-09-09 14:05:05987browse

How to remove duplicate values ​​stored in reverse order from MySQL table?

To understand this concept, we are using data from table 'Details_city' as follows -

mysql> Select * from details_city;
+--------+--------+
| City1  | City2  |
+--------+--------+
| Delhi  | Nagpur |
| Delhi  | Mumbai |
| Nagpur | Delhi  |
| Katak  | Delhi  |
| Delhi  | Katak  |
+--------+--------+
5 rows in set (0.00 sec)

Now, the following query will Remove inverted duplicate values ​​from details_city table-

mysql> Select a.city1,a.city2 from details_city a WHERE a.city1 <= a.city2;
+-------+--------+
| city1 | city2  |
+-------+--------+
| Delhi | Nagpur |
| Delhi | Mumbai |
| Delhi | Katak  |
+-------+--------+
3 rows in set (0.06 sec)

The above is the detailed content of How to remove duplicate values ​​stored in reverse order from MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete