column reference is ambigous
means that the database system cannot guess what entity an expression refers to.
This can be because you are using JOINs, sub queries or multiple FROMs in your SQL One example:
SELECT id
FROM payments
JOIN bookings ON payment_id = id
In the above example, if both payments
& bookings
have an attribute called id
, you will get the above error.
In this case you would fix it by using aliases, such as:
SELECT p.id
FROM payments AS p
JOIN bookings AS b ON b.payment_id = p.id
Another possibility: You are using variables with the same name as your attributes inside your SQL statement. If you have an attribute booking_id
and also a variable booking_id
, the system cannot know, which of the two you mean. To fix this, you can choose different names for your variables. Personally, I always add an underscore to my variable names as this character is forbidden at the beginning of an attribute name (such as _booking_id
).
In your particular case, it seems that both relations you´ve added in FROM share attribute names and therefore the system needs clarity, which you are refering to.