Jump to content

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.