I have a table like this:
+----+-----------+---------+----------+
| id | from_city | to_city | distance |
+----+-----------+---------+----------+
| 1 | Ajmer | Jodhpur | 200 |
| 2 | Jodhpur | Ajmer | 200 |
| 3 | Jaipur | Jodhpur | 300 |
| 4 | Jodhpur | Jaipur | 300 |
| 5 | Kota | Udaipur | 300 |
| 6 | Udaipur | Kota | 300 |
| 7 | Jaipur | Ajmer | 100 |
| 8 | Ajmer | Jaipur | 100 |
+----+-----------+---------+----------+
Now as from above table, id 1 and 2 are similar. So I'm trying to get the output like
+-----------+---------+----------+
| from_city | to_city | distance |
+-----------+---------+----------+
| Ajmer | Jodhpur | 200 |
| Jaipur | Jodhpur | 300 |
| Kota | Udaipur | 300 |
| Jaipur | Ajmer | 100 |
+-----------+---------+----------+
I've tried UNION
, and self join but didn't succeded.
Please help.