severndigital Posted November 13, 2008 Share Posted November 13, 2008 I would like to do the following, but I can't seem to figure out if it's possible and if so the syntax. "SELECT ord.*,usr.*,other.* FROM order_list ord IF(ord.shipid < 300000 THEN INNER JOIN user_list usr ON ord.shipid = usr.id) elseif(ord.shipid > 300000 THEN INNER JOIN other_list other ON ord.shipid = other.id) WHERE ord.complete = 1" can anyone point me in the right direction?? Thanks, C Quote Link to comment https://forums.phpfreaks.com/topic/132570-using-if-then-for-inner-join/ Share on other sites More sharing options...
severndigital Posted November 13, 2008 Author Share Posted November 13, 2008 Just to keep the thread going and let anyone know where i am at. i also tried the following with no avail SELECT ord.*,usr.*,ship.* FROM order_list ord CASE WHEN shiptype = 'prof' THEN (INNER JOIN user_list usr ON ord.userid = usr.id INNER JOIN user_list ship ON order.userid = ship.id) WHEN shiptype = 'brief' THEN (INNER JOIN user_list usr ON ord.userid = usr.id INNER JOIN tbl_brf_shipping ship ON order.userid = ship.id) WHEN shiptype = 'joan' THEN (INNER JOIN joan_user_list usr ON ord.userid = usr.id INNER JOIN joan_user_list ship ON order.userid = ship.id) END WHERE complete = '1' no go. if anyone knows how to do this .. please help out Quote Link to comment https://forums.phpfreaks.com/topic/132570-using-if-then-for-inner-join/#findComment-689388 Share on other sites More sharing options...
Barand Posted November 13, 2008 Share Posted November 13, 2008 SELECT blah FROM ... WHERE condition1 UNION SELECT blah FROM ... WHERE condition2 Quote Link to comment https://forums.phpfreaks.com/topic/132570-using-if-then-for-inner-join/#findComment-689488 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.