0

这是我的简单 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'
4

1 回答 1

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
于 2012-09-13T05:55:27.423 回答