SELECT
a.*,
CASE
WHEN a.in_out = 'in'
THEN
bp.purchase_num
END AS purchase_num
FROM
psom_stock_detail_info a
LEFT JOIN psom_store_info psi ON psi.id = a.store_id
LEFT JOIN psom_purchase_info b ON b.id = a.order_id
LEFT JOIN psom_purchase_produce_info bp ON bp.purchase_id = b.id
上面代码所示:使用case when then 方法
百度了一下,在一个case中暂时没有找到能够返回多个值的方法。