I've come across this error in MySQL for the join clause but I'm fairly new to the JOIN
argument and I'm not sure what this means. Can anyone help?
Column 'id' in where clause is ambiguous
SELECT * FROM (`venues`)
JOIN `venues_meta` ON `venues_meta`.`venue_id` = `venues`.`id`
WHERE `id` = '12'
You may see an error that says something like Column 'id' in field list is ambiguous . This error means that there is a field name that is present in more than one table, so it needs to be scoped with the table name to avoid ambiguity: using orders.id instead of just id will resolve the issue.
The "ambiguous column" error means that there's a reference to a column identifier, and MySQL has two (or more) possible columns that match the specification. In this specific case, it's the reference to CategoryID column in the WHERE clause.
Ambiguity errors occur when erasure causes two seemingly distinct generic declarations to resolve to the same erased type, causing a conflict.
Fixing the error To fix this, simply add the tablename or alias for the table you want to work with. If you are writing the query yourself, this is a bit easier to deal with as you will know which table you meant to use. In our example, we should add the alias for the oc_customer table, c, to the column names.
You need to fully qualify id
because venues
and venues_meta
both have a column called id
.
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