I am learning MySQL using a next.tech course that relies on the following schema:
My current task is to find the average number of hours worked on one specific
The syntax of your SQL query seems to be the main problem behind the first error.
you are doing SELECT-FROM-WHERE-JOIN
, but the actual sequence should be SELECT-FROM-JOIN-WHERE
.
Your second query (which is returning a wrong value) has the correct syntax, which is why it returns something.
Secondly, you should be comparing projects.id
with project_employees.project_id
, not project_employees.employee_id
. Therefore, your query should be something like -
SELECT AVG(hours) FROM project_employees
JOIN projects
ON project_employees.project_id = projects.id
WHERE name = 'Washington Avenue Barber';