3

跟随代码给了我一个模棱两可的列 DRIVER.driv_id 错误,有什么帮助吗?

SELECT DRIVER.driv_id, DRIVER.firstName, DRIVER.surName, DRIVER.nationality,   TEAMSTANDING.teamName, RESULTS.points
FROM TEAMSTANDING INNER JOIN DRIVER ON TEAMSTANDING.driv_id=DRIVER.driv_id,
RESULTS INNER JOIN DRIVER ON RESULTS.driv_id=DRIVER.drv_id
WHERE TEAMSTANDING.comp_id=2
GROUP BY DRIVER.driv_id;
4

2 回答 2

7

您必须尝试多次添加驱动程序表以便创建它

SELECT 
    DRIVER.driv_id, DRIVER.firstName, DRIVER.surName, DRIVER.nationality,   TEAMSTANDING.teamName, RESULTS.points   
FROM 
    TEAMSTANDING
    INNER JOIN 
        DRIVER
ON 
        TEAMSTANDING.driv_id=DRIVER.driv_id
    INNER JOIN 
        RESULTS 
    ON 
        RESULTS.driv_id=DRIVER.drv_id
WHERE 
    TEAMSTANDING.comp_id=2
GROUP BY 
    DRIVER.driv_id;
于 2013-04-26T06:41:53.577 回答
0

您在查询中已将 DRIVER 连接到两次,因此您有两个别名为 DRIVER 的表,并且您从两者中都使用了 driv_id。

将另一个表别名为其他表,或者,如果不需要,则将其从 JOIN 中删除。

于 2013-04-25T20:25:22.600 回答