Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading