0

I am doing a web app similar to SkyScanner and I have a database where I save single flight entities (origin, destination). Let's imagine the database have these 3 flight entities:

  • BCN,MAD
  • MAD,LON
  • LON,MIA

The user asks for an itinerary between BCN(barcelona) and MIA(miami). How can I get this join? (Ignoring the number of stops for simplicity.) It needs to be dynamic solution as this is just an example and we can have thousands of flights entities in db.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
pquin92
  • 21
  • 2
  • 8
  • Simialr question [here](http://stackoverflow.com/questions/16513418/how-to-do-the-recursive-select-query-in-mysql) where you would need recursive query. – SMA Apr 23 '16 at 15:36
  • ok I checked the solution using a PROCEDURE. But where can I create the procedure??? as an annotation in my flight entity?? how? – pquin92 Apr 23 '16 at 16:46
  • What does the resultset for this query look like? What columns do you expect returned? for example, The number of "flights" or "hops"? The number of layovers? Did you want the total miles? If there multiple routes, what did you want to return? For example, if there's a ('BCN','LON') tuple. And obviously you want to avoid routes that return to a destination already visited, e.g exclude BCN->MAD->LON->MAD->MIA. Are these flight entities one way? That is, the return flight MAD->BCN would be a separate entity from BCN->MAD? – spencer7593 Apr 23 '16 at 19:30

0 Answers0