简体   繁体   中英

error 1052: column 'LastName' in field list is ambiguous

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;

Change SELECT LastName to SELECT C.LastName .

Both the CUSTOMER and ARTIST tables have a LastName column. It's not clear which of the two LastName columns you're referring to, thus "the LastName column is ambiguous".

By prefixing it with the table alias C , you're specifying that you want the LastName column from the CUSTOMERS table .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM