Home > Back-end >  Big Query issues: Im getting both a column name ambiguous error or unrecognized name if I specify ta
Big Query issues: Im getting both a column name ambiguous error or unrecognized name if I specify ta

Time:04-20

I am a beginner, but I am a little stumped as to why I keep getting errors. I thought specifying the table would work. Do I have to specify the database as well? If I have to add my project name 'April-17' also I will loose my mind.

SELECT departments.department_id
FROM april-17.employee_data.departments d
FULL JOIN april-17.employee_data.employees e
ON d.department_id=e.department_id

CodePudding user response:

You probably want

SELECT d.department_id
FROM departments d
FULL JOIN employees e
ON d.department_id=e.department_id

If you only have SELECT department_id it won't know which table you want department_id from (could be d or could be e), hence the "ambiguous" error message. But you have aliased the table to d so you also can't use SELECT departments.department_id, hence the "unrecognized name" error message.

CodePudding user response:

Do you mean your database name? What errors are you getting? I will re-write your query, I hope you find this useful

SELECT <insert list of field you want select here> FROM departments d JOIN employee_data e on d.department_id = e.department_id
  •  Tags:  
  • sql
  • Related