1
chggg OP 应该是 order 表是主表, provider 表要去左连 order 表,还有其它表要左连 order 表
|
2
txoooy 2016-06-27 13:31:58 +08:00
用 union 吧, 举个例子:
""" SELECT o.id AS order_id, p. NAME AS provider_name FROM test.order o INNER JOIN test.provider p ON o.order_type = 3 AND o.provider_Id = p.id UNION SELECT o.id AS order_id, p. NAME AS provider_name FROM test.order o INNER JOIN test.drug_provider p ON o.order_type != 3 AND o.drug_provider_id = p.id """ |