0

Hi i need use this sql on mysql.

WITH destinations (departure, arrival, connections, cost) AS
    (SELECT a.departure, a.arrival, 0, price
            FROM flights a 
            WHERE a.departure = 'Chicago' OR
                  a.departure = 'New York'
     UNION ALL 
     SELECT r.departure, b.arrival, r.connections + 1,
                  r.cost + b.price 
            FROM destinations r, flights b 
            WHERE r.arrival = b.departure) 
SELECT departure, arrival, connections, cost 
       FROM destinations

HOW i can use this on mysql?
Thanks a lot.

Joseph

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by josephbarros
0
SELECT a.departure, a.arrival, 0 AS connections, price AS cost FROM flights AS a WHERE a.departure = 'Chicago' OR a.departure = 'New York'
UNION
SELECT r.departure, b.arrival, r.connections + 1, r.cost + b.price AS cost FROM destinations r, flights b WHERE r.arrival = b.departure
0
SELECT a.departure, a.arrival, 0 AS connections, price AS cost FROM flights AS a WHERE a.departure = 'Chicago' OR a.departure = 'New York'
UNION
SELECT r.departure, b.arrival, r.connections + 1, r.cost + b.price AS cost FROM destinations r, flights b WHERE r.arrival = b.departure

=}

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.