错误1052:字段列表中的列“ LastName”不明确

时间:2018-10-31 03:02:49

标签: mysql

CREATE VIEW CustomerInterestsView AS
    SELECT LastName AS CustomerLastName,
            C.FirstName AS CustomerFirstName,
            A.LastName AS ArtistName
    FROM
        CUSTOMER AS C
            JOIN
        CUSTOMER_ARTIST_INT AS CAI ON C.CustomerID = CAI.CustomerID
            JOIN
        ARTIST AS A ON CAI.ArtistID = A.ArtistID;

1 个答案:

答案 0 :(得分:3)

SELECT LastName更改为SELECT C.LastName

CUSTOMERARTIST表都有一个LastName列。您所指的是两个LastName列中的哪一个,目前尚不清楚,因此“ LastName列不明确”。

通过在表别名C前面加上前缀,您指定要从LastName表中的CUSTOMERS