Resolved: why this code not valid
SELECT
m.emp_no, e.first_name,e.last_name,e.hire_date,t.title,t.from_date, d.dept_name
from
dept_number d
join
dept_manager m on d.dept_no = m.dept_no
join
employees e on m.emp_no = e.emp_no
join
titles t on e.emp_no = t.emp_no;
the error >>
Error Code: 1146. Table 'employees.dept_number' doesn't exist
Hi Abdelrahman!
Thanks for reaching out.
There is not such a table dept_number. Please, use the departments table. The code is:
SELECT
m.emp_no,
e.first_name,
e.last_name,
e.hire_date,
t.title,
t.from_date,
d.dept_name
FROM
departments d
JOIN
dept_manager m ON d.dept_no = m.dept_no
JOIN
employees e ON m.emp_no = e.emp_no
JOIN
titles t ON e.emp_no = t.emp_no;
Hope this helps.
Best,
Tsvetelin
Thank you for your concern
Hi Abdelrahman!
You are very welcome!
Best,
Tsvetelin
why this code is not working
select
e.first_name,
e.last_name,
e.hire_date,
m.form_date,
d.dept_name
from
employees e
join
dept_manager m on e.emp_no = m.emp_no
join
departments d on m.dept_no = d.dept_no;
In the SELECT fields' names it is "m.from_date" , then it would work just fine.
Hi Abdullah and Mohamed!
Thanks for reaching out.
@: Mohamed
Thanks for sharing this piece of information with the Community!
@: Abdullah
As Mohamed explained you should use m.from_date
instead of m.form_date
. This will resolve the issue.
Hope this helps.
Best,
Tsvetelin