Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column in where clause is ambiguous - What does that mean?

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'
like image 513
Ben Avatar asked May 19 '11 17:05

Ben


People also ask

What does ambiguous column mean in SQL?

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.

WHERE clause is ambiguous in SQL?

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.

What is ambiguous error?

Ambiguity errors occur when erasure causes two seemingly distinct generic declarations to resolve to the same erased type, causing a conflict.

How do I fix error 1052 in SQL?

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.


1 Answers

You need to fully qualify id because venues and venues_meta both have a column called id.

like image 57
Chris Morgan Avatar answered Nov 15 '22 15:11

Chris Morgan