Jump to content

using IF THEN for INNER JOIN


severndigital

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/132570-using-if-then-for-inner-join/
Share on other sites

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.