
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to delete the duplicate values stored in reverse order from MySQL table?
To understand this concept, we are using the 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 delete the reverse 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)
- Related Articles
- How can I create a stored procedure to delete values from a MySQL table?
- How to delete all the duplicate records in a MySQL table?
- How to delete a single value from a MySQL table with duplicate records?
- How to remove duplicate values from a MySQL table using LEFT JOIN?
- How to order return duplicate column values only once in MySQL?
- Selecting the top occurring entries in MySQL from a table with duplicate values?
- How to repeat the values stored in a data column of MySQL table?
- How can we delete a MySQL stored function from the database?
- How to delete a column from a table in MySQL?
- How do we find the duplicate values available in a MySQL table?
- How to write a MySQL stored function that updates the values in a table?
- How can I create a MySQL stored procedure that returns multiple values from a MySQL table?
- Fetch specific rows from a MySQL table with duplicate column values (names)?
- How to write a MySQL stored function that inserts values in a table?
- Delete all the records from a MySQL table?

Advertisements