2012-09-13 70 views
0

這是我簡單的sql代碼。當在執行它的拋出和錯誤。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' 
+1

我想你忘了加入'product_hscodes'表。 –

+0

不,我試過了。如果我添加到「從」其拋出「mi.code」,也沒有發現 – Mifas

+0

,那麼你爲什麼加入這個'h.code = product_hscodes.hscode'加入hscode h? –

回答

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 
相關問題