I'm trying to work out a select statement that will pull data from a few different tables based on common id's across the tables.
My test code is:
In this case, the four tables are contact, dept, salary and supervisor. The problem that I am having is that I want to list all first and last names, but some don't have departments assigned so with the current select statement, those entries would be excluded. How can I adjust my select to still list those that don't have departments but maybe put a - where no department exists?
I can get this to work in Oracle with:
But this doesn't work in MySQL.
My test code is:
Code:
select
c.firstname||' '||c.lastname,
d.dept_name,
s.salary_level,
su.supervisor_name,
from contact c, dept d, salary s, supervisor su
where c.id=su.c_id
and d.dept_id=c.dept_id
and s.salary_id=c.salary_id
order by c.lastname
;
In this case, the four tables are contact, dept, salary and supervisor. The problem that I am having is that I want to list all first and last names, but some don't have departments assigned so with the current select statement, those entries would be excluded. How can I adjust my select to still list those that don't have departments but maybe put a - where no department exists?
I can get this to work in Oracle with:
Code:
select
c.firstname||' '||c.lastname,
d.dept_name,
s.salary_level,
su.supervisor_name,
from contact c, dept d, salary s, supervisor su
where c.id=su.c_id
and d.dept_id(+)=c.dept_id
and s.salary_id=c.salary_id
order by c.lastname
;