Home > Database > Mysql Tutorial > body text

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

PHPz
Release: 2023-09-09 14:05:05
forward
957 people have browsed it

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template