Reputation: 157
Follow code is giving me an ambiguous column DRIVER.driv_id error, any help?
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;
Upvotes: 4
Views: 17334
Reputation: 131
You must try this you add driver table multiple times so that this is created
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;
Upvotes: 8
Reputation: 1208
You've got DRIVER joined to twice in your query, so you have two tables aliased as DRIVER and you use driv_id from both.
Either alias the other table as something else or, if it's not needed, drop it from the JOIN.
Upvotes: 0