I have the following SQL and it throws the error Ambiguous column name 'id'
select tbl_registration.*, tbl_ebp.name as ebp_name, tbl_Users.id as user_id, tbl_ebp.id as linked_ebp_id
from tbl_registration
left outer join tbl_ebp on tbl_ebp.id = tbl_registration.ebp_id
left outer join tbl_users on tbl_registration.email = tbl_users.username
where id = [PARAM]p_id
I've read some articles on this, but can't find a working solution for my code. Any help much appreciated.
Ambiguity errors occur when erasure causes two seemingly distinct generic declarations to resolve to the same erased type, causing a conflict.
Ambiguous error means that you are calling a certain field in which exist in both Table and the SQL has no idea where to get it.
Your WHERE clause id needs to be more specific, include the table name:
WHERE table.id = [PARAM]p_id
If two things share the same name, this is where the ambiguity steps in. In this case multiple tables in your SQL contain the "id" column.
SQL has the intelligence to disambiguate column names if the column name is unique across the current set of tables being touched - hence most of the time you don't need to prefix column names with table names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With