How can I get all possible flights between two cities?

I have a MySQL table called flight data as shown below:

enter image description here

Expected results:

  • Bangalore to Chennai
  • Bangalore to Delhi
  • Bangalore to Kolkata
  • Bangalore to Mumbai
  • Chennai to Bangalore
  • Chennai to Delhi
  • Chennai to Kolkata
  • Chennai to Mumbai
  • Delhi to Chennai
  • Delhi to Bangalore
  • Delhi to Kolkata
  • Delhi to Mumbai
  • Kolkata to Chennai
  • Kolkata to Delhi
  • Kolkata to Bangalore
  • Kolkata to Mumbai
  • Mumbai to Chennai
  • Mumbai to Delhi
  • Mumbai to Kolkata
  • Mumbai to Bangalore

not with the same city.

+3


source to share


1 answer


try it,



SELECT fl1.flight_city,fl2.flight_city FROM `flight_details` as fl1 JOIN `flight_details` as fl2 on fl2.fid != fl1.fid 

      

+1


source







All Articles