SQL Server 教科书中的示例查询出现错误消息,“Ambiguous column name 'V_CODE'" [duplicate]

oxcyiej7  于 2022-12-10  发布在  其他
关注(0)|答案(1)|浏览(165)

This question already has answers here:

SQL column reference "id" is ambiguous (5 answers)
Closed 5 days ago.
For my homework, I have to enter example queries from the book to sql. There are also example database I downloaded for the homework and properly put them into SQL. The following is what I have to put in but an error message comes up.

SELECT V_CODE, V_NAME, V_STATE, P_CODE, P_DESCRIPT, P_PRICE * P_QOH AS TOTAL
FROM PRODUCT P JOIN VENDOR V ON P.V_CODE = V.V_CODE
WHERE V_STATE IN ('TN','KY')
ORDER BY V_STATE, TOTAL DESC;

--Total value of products from Tennessee and Kentucky

Ambiguous column name 'V_CODE'
Not sure how to fix.
I had to put in an example query from the homework but an error message comes up.
"Ambiguous column name 'V_CODE'"

rsaldnfx

rsaldnfx1#

您需要选择要从中选择V_CODE的表。在本例中,它取自PRODUCT表。

SELECT P.V_CODE, V_NAME, V_STATE, P_CODE, P_DESCRIPT, P_PRICE * P_QOH AS TOTAL
FROM PRODUCT P JOIN VENDOR V ON P.V_CODE = V.V_CODE
WHERE V_STATE IN ('TN','KY')
ORDER BY V_STATE, TOTAL DESC;
--Total value of products from Tennessee and Kentucky

相关问题