'Column in field list is ambiguous despite I have correct table names
Here's the code, in theory this should work, right? But when I run this, the error comes up
"#1052 - Column 'spotID' in field list is ambiguous"
SELECT start, end, spotID FROM bookings
INNER JOIN glampingspot ON (bookings.spotID = glampingspot.spotID)
WHERE glampingspot.venueID = 1
AND glampingspot.maxPeople >= 3
And yes I am 1000% sure that the names of the tables are "bookings" and "glampingspot", and they have the same key "spotID"
Solution 1:[1]
SELECT start, end, bookings.spotID FROM bookings
INNER JOIN glampingspot ON (bookings.spotID = glampingspot.spotID)
WHERE glampingspot.venueID = 1
AND glampingspot.maxPeople >= 3
It is always a good practice to resolve the scope of columns so that it is clear that which column comes from which table in the output.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rinkesh P |
