Trying to make a conditional join
Can someone tell me why the following code wont work? I think it's pretty self explonatory so no need try explain what I want to do. (ask if need)
Code:
SELECT * FROM messages AS msg
CASE msg.app_type
WHEN 'study_abroad' THEN LEFT JOIN apps_study_abroad ON msg.application_id=apps_study_abroad.id
WHEN 'study_in_china' THEN LEFT JOIN apps_study_in_china ON msg.application_id=apps_study_in_china.id
END CASE
Re: Trying to make a conditional join
How about just joining both 3 tables and just put a where clause at the end?
Re: Trying to make a conditional join
yeah, that should work. thanks mate
Re: Trying to make a conditional join