Error 1052 - "Column '%s' in field list is ambiguous". This error appears because there are more than one identically named columns referenced in the query.
Error 1052 - "Column '%s' in field list is ambiguous".
This error appears because there are more than one identically named columns referenced in the query. IE:
SELECT column,
column
FROM TABLE_1,
TABLE_2
WHERE ...
The solution is to prefix the table or the table alias the respective column is from.
Using the table name
SELECT TABLE_1.column,
TABLE_2.column
FROM TABLE_1,
TABLE_2
WHERE ...
Using the table alias
SELECT t1.column,
t2.column
FROM TABLE_1 t1,
TABLE_2 t2
WHERE ...
The AS
is optional for table aliases.
Caveat
You'll probably want to provide a column alias in order to know which value you retrieve:
SELECT t1.column AS T1_column,
t2.column AS T2_column
FROM TABLE_1 t1,
TABLE_2 t2
WHERE ...