ตาราง Details_city มีคู่เมืองซ้ำกันแต่สลับลำดับ:
mysql> Select * from details_city; +--------+--------+ | City1 | City2 | +--------+--------+ | Delhi | Nagpur | | Delhi | Mumbai | | Nagpur | Delhi | | Katak | Delhi | | Delhi | Katak | +--------+--------+ 5 rows in set (0.00 sec)
ลบคู่ซ้ำย้อนกลับ โดยเก็บเฉพาะคู่ที่ city1 <= city2 (เรียงตัวอักษร):
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)
เหลือ 3 คู่ที่ไม่ซ้ำกันในลำดับที่กำหนด