这是我简单的sql代码。在执行其抛出和错误时。
无法绑定多部分标识符“product_hscodes.hscode”。
select DISTINCT mi.*,csq.contract_code
from master_items mi
join contract_shipment_qty csq on csq.item_code = mi.code
join contract c on c.code = csq.contract_code
join master_item_products mp on mp.master_item = mi.id
join hscode h on h.code = product_hscodes.hscode
where csq.shipment_id = 6
and csq.contract_code = '046V-12-A04-05'
and mi.code = 'M165'
and h.code = '12345'
答案 0 :(得分:1)
您尚未加入product_hscodes
表。
from master_items mi
join contract_shipment_qty csq on csq.item_code = mi.code
join contract c on c.code = csq.contract_code
join master_item_products mp on mp.master_item = mi.id
join product_hscodes
on product_hscodes.fk = <primary table>.pk //<<Have you joined this table?
join hscode h on h.code = product_hscodes.hscode