I am currently working on using inner joins in SQL, I have attempted to used aliases to fix this problem but it just changes the name that is "unrecognizable". Database name is employee_data. Table names are employees and departments. The error is being picked up on the last line of code. Any suggestions would be appreciated.
SELECT
employees.name as employee_name,
employees.role as employee_role,
departments.name as department_name
FROM
`project-1-357623.employee_data.employees`
INNER JOIN employee_data.departments
ON
employees.department_id = departments.department_id;
Hi Please try this code
enter code here
SELECT employees.name as employee_name,
employees.role as employee_role,
departments.name as department_name
FROM employees
INNER JOIN departments
ON employees.department_id = departments.department_id
Related
This is giving me an unrecognized name error. Why?
SELECT
employees.name AS employee_name,
employees.role AS employee_role,
departments.name AS department_name
FROM
`strange-calling-318804.employee_data.Employees`
JOIN
`strange-calling-318804.employee_data.departments`
ON employees.department_id = departments.department_id
Unrecognized name: employees at [9:8]
enter image description here
you are missing aliases employees and departments after full table references! you use them in ON clause but you missed to define them!
SELECT
employees.name AS employee_name,
employees.role AS employee_role,
departments.name AS department_name
FROM
`strange-calling-318804.employee_data.Employees` as employees
JOIN
`strange-calling-318804.employee_data.departments` as departments
ON employees.department_id = departments.department_id
You need to give your tables aliases. I would recommend abbreviations for the table names:
SELECT e.name AS employee_name, e.role AS employee_role,
d.name AS department_name
FROM `strange-calling-318804.employee_data.Employees` e JOIN
`strange-calling-318804.employee_data.departments` d
ON e.department_id = d.department_id;
I'm working on an employee_data dataset which has two tables; employees and departments. I'm trying to join data from the employee table to the departments table using department_id as the primary key. It keeps giving me an error message. Please where am I missing it?
SELECT name AS departments_name,
(
SELECT name AS employees_name,
FROM `my-first-analysis.employee_data.employees`
)
FROM `my-first-analysis.employee_data.departments`
JOIN departments ON departments.department_id = employees.department_id
Like this:
SELECT departments.name AS departments_name,
employees.name AS employees_name,
From employees
Left JOIN departments ON departments.department_id = employees.department_id
This is giving me an unrecognized name error. Why?
SELECT
employees.name AS employee_name,
employees.role AS employee_role,
departments.name AS department_name
FROM
`strange-calling-318804.employee_data.Employees`
JOIN
`strange-calling-318804.employee_data.departments`
ON employees.department_id = departments.department_id
Unrecognized name: employees at [9:8]
enter image description here
you are missing aliases employees and departments after full table references! you use them in ON clause but you missed to define them!
SELECT
employees.name AS employee_name,
employees.role AS employee_role,
departments.name AS department_name
FROM
`strange-calling-318804.employee_data.Employees` as employees
JOIN
`strange-calling-318804.employee_data.departments` as departments
ON employees.department_id = departments.department_id
You need to give your tables aliases. I would recommend abbreviations for the table names:
SELECT e.name AS employee_name, e.role AS employee_role,
d.name AS department_name
FROM `strange-calling-318804.employee_data.Employees` e JOIN
`strange-calling-318804.employee_data.departments` d
ON e.department_id = d.department_id;
This question already has answers here:
Unrecognized name: employees at [9:8]
(2 answers)
Closed 10 months ago.
When I try to run the code below, I get the error:
Unrecognized name: employees at [7:1]
There are two tables in the database employee_data. One is called employees and the other departments.
SELECT
employees.name as employee_name,
employees.role as employee_role,
departments.name as department_name
FROM
`potent-electron-345605.employee_data.employees`
INNER JOIN
employee_data.departments ON employees.department_id = departments.department_id
I also tried the code below (using the database.table), but got the error
Unrecognized name: employee_data at [7:1]
SELECT
employees.name AS employee_name,
employees.role AS employee_role,
departments.name AS department_name
FROM
`potent-electron-345605.employee_data.employees`
INNER JOIN
employee_data.departments ON employee_data.employees.department_id = employee_data.departments.department_id
You have a trailing ` mark on line 7 that you should eliminate. Also, try using aliases:
SELECT
employees.name as employee_name,
employees.role as employee_role,
departments.name as department_name
FROM `potent-electron-345605.employee_data.employees` AS E
INNER JOIN employee_data.departments AS D
ON E.department_id = D.department_id
This is giving me an unrecognized name error. Why?
SELECT
employees.name AS employee_name,
employees.role AS employee_role,
departments.name AS department_name
FROM
`strange-calling-318804.employee_data.Employees`
JOIN
`strange-calling-318804.employee_data.departments`
ON employees.department_id = departments.department_id
Unrecognized name: employees at [9:8]
enter image description here
you are missing aliases employees and departments after full table references! you use them in ON clause but you missed to define them!
SELECT
employees.name AS employee_name,
employees.role AS employee_role,
departments.name AS department_name
FROM
`strange-calling-318804.employee_data.Employees` as employees
JOIN
`strange-calling-318804.employee_data.departments` as departments
ON employees.department_id = departments.department_id
You need to give your tables aliases. I would recommend abbreviations for the table names:
SELECT e.name AS employee_name, e.role AS employee_role,
d.name AS department_name
FROM `strange-calling-318804.employee_data.Employees` e JOIN
`strange-calling-318804.employee_data.departments` d
ON e.department_id = d.department_id;