[MySQL] join bercabang, conditional join.

SELECT m_inout.m_inout_id,
c_order.document_no so,
FROM m_inout
LEFT JOIN c_order
on m_inout.c_order_id = c_order.c_order_id
LEFT JOIN c_bpartner
on if(isnull(m_inout.c_order_id),
c_bpartner.c_bpartner_id = m_inout.c_bpartner_id,
c_bpartner.c_bpartner_id = c_order.c_bpartner_id)
WHERE m_inout.m_transaction_type_id = 3
AND m_inout.app_org_id = ‘5’;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s