MySQL Forums
Forum List  »  German

case when in on clause
Posted by: jens ubert
Date: February 10, 2009 02:18PM

Wie erledigt man ein sauberes JOIN mit einem CASE-ELSE-END Construct in einer ON CLAUSE?

Code:

select * FROM tab3, tab1
LEFT JOIN (tab2) ON (tab2.id_kurs_ort = CASE WHEN tab3.ort_id_sessionwiekurs=1 then tab3.ort_id_vorschlag else tab1.ort_id END)
...

... mit FROM tab3, tab1 bekomme ich den Fehler: Unknown column 'tab3.ort_id_sessionwiekurs' in 'on clause'

... mit FROM tab1, tab3 bekomme ich den Fehler: Unknown column 'tab1.ort_id' in 'on clause'

Die Fehler-GrĂ¼nde sind unter MySQL5 schon logisch aber, wie biegt man denn so was hin. Probiere es schon seit Stunden, aber nix geht ...

Eine Idee?

Options: ReplyQuote


Subject
Views
Written By
Posted
case when in on clause
3101
February 10, 2009 02:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.