(select `name` from auth_warehouse where code = ip.invCode) invName,
ipd.invSpaceCode,
(select `name`
aw.name AS invName,
from auth_space
aspc.name AS invSpaceName,
where code = ipd.invSpaceCode and invWarehouseCode = ip.invCode) invSpaceName,
bp.ggxh,
bp.ggxh,
bp.cpmctymc AS productName,
bp.cpmctymc productName,
bu.lowStockNum,
bu.lowStockNum,
bu.overStockNum,
bu.overStockNum,
bu.recentDateTime,
bu.recentDateTime,
bu.isDateBy
bu.isDateBy
FROM inv_product AS ip
from inv_product ip
LEFT JOIN basic_udirel AS bu ON ip.relIdFk = bu.id
left join basic_udirel bu on ip.relIdFk = bu.id
LEFT JOIN basic_products AS bp ON bu.uuid = bp.uuid
left join basic_products bp on bu.uuid = bp.uuid
LEFT JOIN inv_product_detail AS ipd ON ip.relIdFk = ipd.relId AND IFNULL(ip.batchNo, 'empty') = IFNULL(ipd.batchNo, 'empty') AND ip.invCode = ipd.invCode
left join inv_product_detail ipd
LEFT JOIN auth_warehouse AS aw ON aw.code = ip.invCode
on ip.relIdFk = ipd.relId and IFNULL(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
LEFT JOIN auth_space AS aspc ON aspc.code = ipd.invSpaceCode AND aspc.invWarehouseCode = ip.invCode