执行SQL时出现错误
不明确的列名“Chem_Num”
我该怎么办?
我在代码中尝试了此方法,但仍然不确定我做错了什么
SELECT
Chem_Num, Chem_Retail_Name,
Carried_Num as "Item Carry",
Tech_LName as "Driver",
Job_Num, Used_Qty AS "Used on Job",
(Carried_Outbound - Carried_Return) AS "Gone from Truck"
FROM
PEPS.CHEMICAL
JOIN
PEPS.CARRIED ON CHEMICAL.Chem_Num = CARRIED.Chem_Num
JOIN
PEPS.ASSIGNMENT ON CARRIED.Assign_Num = ASSIGNMENT.Assign_Num
JOIN
PEPS.TECHNICIAN ON ASSIGNMENT.Tech_Num = TECHNICIAN.Tech_Num
JOIN
PEPS.USED ON CHEMICAL.Chem_Num = USED.Chem_Num
WHERE
Chem_Num IN (101, 103, 107)
ORDER BY
Chem_Num ASC, Carried_Num ASC;
1条答案
按热度按时间dgtucam11#
这意味着您联接的多个表具有Chem_Num列,因此查询不知道您需要哪一个。
您必须在列名前面加上它所来自的表的前缀,就像您在连接中所做的那样:
CHEMICAL.Chem_Num=USED.Chem_Num