From SQL(Ora8i) to MySQL

I wished if these SQL were similar but I tried to use my SQL that I used to run in Oracle in MySQL but I get an error message. (I wanted the source_city to be from an input from the form so I called it s_city and dest city as $d_city.
I hear that MySQL doesnt use CONNECT BY... what else can I use?
Also Can I use a CASE in SELECT? (Thank you)

$a_query = "SELECT *
FROM (SELECT Flight_num, (CASE WHEN LEVEL=1 THEN Source_city
ELSE PRIOR Source_city END) AS S_City, Dest_city,
(CASE WHEN LEVEL=1 THEN (arr_time - dept_time)
WHEN LEVEL=2 THEN (arr_time - dept_time)+(PRIOR arr_time - PRIOR dept_time)
END) AS Tot_Time FROM Flight
START WITH source_city = $s_city
CONNECT BY PRIOR dest_city = Source_city AND Dest_city = $d_city) ALL_COR
WHERE Dest_city = $d_city";
[840 byte] By [thdwlgP] at [2007-11-19 22:26:50]
# 1 Re: From SQL(Ora8i) to MySQL
From what i remember...there is no "CONNECT BY PRIOR"

In short, you can either reorganise your table so that it does not depend on recursion anymore if that's what you intend to do with that function.

Or rewrite your procedure to process the hierarchy by iteration, not recursion.

Cos if you want to use recursion...the max depth depended on your thread stack size.
But i do know you can read this article (http://dev.mysql.com/tech-resources/articles/hierarchical-data.html) to get a understanding of how it work in MySQL...(As i seldom touch PHP and MySQL now...cos i'm a C/C#/VB developer)

But this is interesting...i seldom see Oracle developers moving to MySQL...
e_har at 2007-11-10 3:57:29 >