SQL-无法绑定多部分标识符

时间:2022-08-16 09:18:21

SQL-无法绑定多部分标识符

While executing the following query, I am getting the Multi Part Identifier could not be bound error. Kindly help.

在执行以下查询时,我得到多部分标识符无法绑定错误。请帮助。

Query:

SELECT 
    C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM 
    CUSTOMER as C, ARTIST as A 
WHERE 
    CUSTOMER_ARTIST_INT.CustomerID = CUSTOMER.CustomerID 
    AND CUSTOMER_ARTIST_INT.ArtistID = ARTIST.ArtistID;

4 个解决方案

#1


1  

Try this

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM CUSTOMER as C, ARTIST as A WHERE CUSTOMER_ARTIST_INT.CustomerID=C.CustomerID AND CUSTOMER_ARTIST_INT.A=ARTIST.ArtistID

#2


1  

You cannot call CUSTOMER_ARTIST_INT.CustomerID without using it in select query..

如果不在select查询中使用它,则无法调用CUSTOMER_ARTIST_INT.CustomerID。

use this:

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM CUSTOMER as C, ARTIST as A,CUSTOMER_ARTIST_INT as CAI WHERE CAI.CustomerID=C.CustomerID AND CIA.ArtistID=A.ArtistID;

#3


0  

try this:

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM CUSTOMER C
inner join ARTIST  A 
on a.CustomerID=c.CustomerID 
AND a.ArtistID=c.ArtistID ;

#4


0  

Never use commas to build relation between tables. Use proper JOINs. In your script you haven't included the table CUSTOMER_ARTIST_INT in the FROM clause and without mentioning the table you can't access the columns ( CUSTOMER_ARTIST_INT.CustomerID and CUSTOMER_ARTIST_INT.ArtistID) .

永远不要使用逗号来构建表之间的关系。使用正确的JOIN。在您的脚本中,您没有在FROM子句中包含表CUSTOMER_ARTIST_INT,并且未提及表,您无法访问列(CUSTOMER_ARTIST_INT.CustomerID和CUSTOMER_ARTIST_INT.ArtistID)。

Change your script like below ,move the conditions from WHERE clause to ON using appropriate JOINS and also try to use aliases for representing the table.

像下面一样更改脚本,使用适当的JOINS将条件从WHERE子句移动到ON,并尝试使用别名来表示表。

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM  CUSTOMER  C
       JOIN CUSTOMER_ARTIST_INT CA ON C.CustomerID=CA.CustomerID
       JOIN ARTIST  A ON CA.ArtistID=A.ArtistID

#1


1  

Try this

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM CUSTOMER as C, ARTIST as A WHERE CUSTOMER_ARTIST_INT.CustomerID=C.CustomerID AND CUSTOMER_ARTIST_INT.A=ARTIST.ArtistID

#2


1  

You cannot call CUSTOMER_ARTIST_INT.CustomerID without using it in select query..

如果不在select查询中使用它,则无法调用CUSTOMER_ARTIST_INT.CustomerID。

use this:

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM CUSTOMER as C, ARTIST as A,CUSTOMER_ARTIST_INT as CAI WHERE CAI.CustomerID=C.CustomerID AND CIA.ArtistID=A.ArtistID;

#3


0  

try this:

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM CUSTOMER C
inner join ARTIST  A 
on a.CustomerID=c.CustomerID 
AND a.ArtistID=c.ArtistID ;

#4


0  

Never use commas to build relation between tables. Use proper JOINs. In your script you haven't included the table CUSTOMER_ARTIST_INT in the FROM clause and without mentioning the table you can't access the columns ( CUSTOMER_ARTIST_INT.CustomerID and CUSTOMER_ARTIST_INT.ArtistID) .

永远不要使用逗号来构建表之间的关系。使用正确的JOIN。在您的脚本中,您没有在FROM子句中包含表CUSTOMER_ARTIST_INT,并且未提及表,您无法访问列(CUSTOMER_ARTIST_INT.CustomerID和CUSTOMER_ARTIST_INT.ArtistID)。

Change your script like below ,move the conditions from WHERE clause to ON using appropriate JOINS and also try to use aliases for representing the table.

像下面一样更改脚本,使用适当的JOINS将条件从WHERE子句移动到ON,并尝试使用别名来表示表。

SELECT C.CustomerID, C.LastName, A.ArtistID, A.LastName 
FROM  CUSTOMER  C
       JOIN CUSTOMER_ARTIST_INT CA ON C.CustomerID=CA.CustomerID
       JOIN ARTIST  A ON CA.ArtistID=A.ArtistID