2017-08-02 10 views
0

をバインドすることができませんでした。左が参加するが、私はこのテーブルを持っている

WS | Cat | Prod | CS | Dis| UserWS | MarA | ModA | MarU | BCIU 

私はいくつかがヌルであっても、すべての行の関係を得るためにそれらを結合する必要があり、私はこれを試してみました:

Select * 
FROM WS 
Left join MarU on MarU.Code=WS.used_brand 
Left join Prod p on p.MarA=Cat.OID 
Left join CS on WS.CS =CS.OID 
Left join Prod pp on WS.product_code=pp.Code 
Left join MarA on WS.customer_car_brand=MarA.Code 
Left join ModA on WS.customer_car_model=ModA.Code 
Left join CS c on c.UserWS=UserWS.Oid 
Left join CS css on css.Dis=Dis.OID 
Left join BCIU on BCIU.Code=WS.used_bci 

私はそれを実行すると、私はこのエラーを取得:

[Err] 42000 - [SQL Server]The multi-part identifier "Cat.OID" could not be bound. 42000 - [SQL Server]The multi-part identifier "UserWS.Oid" could not be bound. 42000 - [SQL Server]The multi-part identifier "Dis.OID" could not be bound. 42000 - [SQL Server]The multi-part identifier "Cat.Name" could not be bound. 42000 - [SQL Server]The multi-part identifier "Prod.Name" could not be bound. 42000 - [SQL Server]The multi-part identifier "Dis.Nombre" could not be bound. 42000 - [SQL Server]The multi-part identifier "UserWS.Nombre" could not be bound. 42000 - [SQL Server]The multi-part identifier "Cat.Segmento" could not be bound.

私が欠けていますか?上記の文で

+1

どこでも 'JOIN'に' Cat'が含まれていないという事実を、私が言うと思います。 –

答えて

2

エラーメッセージは実際には複数のエラーです。私は順番にそれらを扱う。

行は-->で始まるを参照してください:

[Err] 
42000 - [SQL Server]The multi-part identifier "Cat.OID" could not be bound. 
--> Your SQL doesn't mention JOIN Cat table anywhere 

42000 - [SQL Server]The multi-part identifier "UserWS.Oid" could not be bound. 
--> Your SQL doesn't mention JOIN UserWS table anywhere 

42000 - [SQL Server]The multi-part identifier "Dis.OID" could not be bound. 
--> Your SQL doesn't mention JOIN Dis table anywhere 

42000 - [SQL Server]The multi-part identifier "Cat.Name" could not be bound. 
--> Your SQL doesn't mention JOIN Cat table anywhere 

42000 - [SQL Server]The multi-part identifier "Prod.Name" could not be bound. 
--> Your SQL doesn't call the Prod table "Prod", it joins it twice and aliases it as "p" and "pp". refer to p.Name or pp.Name, not Prod.Name 

42000 - [SQL Server]The multi-part identifier "Dis.Nombre" could not be bound. 
--> Your SQL doesn't mention JOIN Dis table anywhere 

42000 - [SQL Server]The multi-part identifier "UserWS.Nombre" could not be bound. 
--> Your SQL doesn't mention JOIN UserWS table anywhere 

42000 - [SQL Server]The multi-part identifier "Cat.Segmento" could not be bound. 
--> Your SQL doesn't mention JOIN Cat table anywhere 
1
Left join Prod p on p.MarA=Cat.OID 

猫は、表または表の別名である必要がありますが、あなたは猫と呼ばれるあなたの文でもないテーブルや別名を持っていません。

手前でLEFT JOIN CAT on [ForeignKey]=CAT.[PrimaryKey]を追加してください。

2

まず、エラーを特定するためにクエリを簡略化します。エラーが示すようにCatが定義されていない、

SELECT * 
FROM WS Left join 
    MarU 
    on MarU.Code = WS.used_brand Left join 
    Prod p 
    on p.MarA = Cat.OID 

:あなたは上で同じエラーを取得します。 CatFROM節のどこにも定義されていないため、これは前方参照の問題ではありません。おそらく、関連するテーブル/ビューを省略しただけです。

関連する問題