尝试连接表错误说标识符无法绑定

时间:2017-02-16 20:59:40

标签: sql sql-server-2012

我试图在job_price_hdr.job_price_hdr_uid = job_price_line.job_price_hdr_uid上加入job_price_hdr这样做会发现错误

Msg 4104,Level 16,State 1,Line 29 无法绑定多部分标识符“job_price_line.job_price_hdr_uid”。

declare @itemid varchar(60)
set @itemid = '3433580'

select     

    inv_mast.item_id,
    job_Price_line.cust_po_no as 'JPL Customer Commitment',
    job_Price_line.commitment_amount as 'JPL EUA',
    inv_loc.max_liability as 'Max Liability Customer Commitment',
    (select item_uom.unit_size 
        from item_uom 
            INNER JOIN inv_mast on inv_mast.inv_mast_uid = item_uom.inv_mast_uid 
            INNER JOIN unit_of_measure ON ( unit_of_measure.unit_id = item_uom.unit_of_measure ) 
        WHERE ( inv_mast.item_id = @itemid and unit_of_measure.unit_description = 'Minimum Quantity to Order' )) as 'MOQ',
    inv_loc.qty_on_hand,
    inv_loc.qty_allocated,
    inv_loc.qty_backordered,
    ( inv_loc.order_quantity +  inv_loc_stock_status.qty_on_special_po + inv_loc_stock_status.qty_on_ds_po ) / (item_uom.unit_size ) as 'Qty on order',
    item_uom.unit_of_measure as 'Sales UOM'
From
inv_loc
INNER join job_price_hdr on (job_price_hdr.job_price_hdr_uid = job_price_line.job_price_hdr_uid)

INNER JOIN inv_mast ON inv_mast.inv_mast_uid = inv_loc.inv_mast_uid
INNER JOIN item_uom ON item_uom.unit_of_measure = inv_mast.default_selling_unit
    AND item_uom.inv_mast_Uid = inv_mast.inv_mast_Uid  
LEFT JOIN inv_loc_stock_status ON inv_loc_stock_status.location_id = inv_loc.location_id
    AND inv_loc_stock_status.inv_mast_uid = inv_loc.inv_mast_uid
INNER JOIN job_price_line ON job_price_line.inv_mast_uid = item_uom.inv_mast_uid 

WHERE
( inv_loc.location_id BETWEEN '200' AND '200' )
    AND  
inv_mast.item_id ='3433580'
    AND
( inv_loc.company_id = '556' )
    AND
( inv_loc.delete_flag = 'N' OR inv_loc.delete_flag IS NULL) 

group by 
item_id, inv_loc.max_liability, inv_loc.qty_on_hand,inv_loc.qty_allocated,inv_loc.qty_backordered,
inv_loc.order_quantity , inv_loc_stock_status.qty_on_special_po, inv_loc_stock_status.qty_on_ds_po,
item_uom.unit_size, item_uom.unit_of_measure, job_Price_line.cust_po_no,job_Price_line.commitment_amount

1 个答案:

答案 0 :(得分:0)

尝试在google或StackOverflow中搜索您收到的错误减去您的代码。

例如,搜索" SQL无法绑定错误"给了我这个链接:

What is a 'multi-part identifier' and why can't it be bound?