PDA

View Full Version : SQL help.


Josué Alba
02-04-2005, 12:13 PM
Hi, I'm haing some SQL problems, the background is the following:

I have a employee tamble where I have a identificator named manager_id the problem is that not all of the employees has a manager so some of them has a null value in there and when making a join it only shows me the employees where there is a Manager. Some of you know how can I obtain all the employees even when they don't have a manager?

Derek
02-04-2005, 12:45 PM
How are you currently returning the results? Can you paste some code here so we can see what you are accessing and how the syntax is written, please?

TJ_Tigger
02-04-2005, 12:54 PM
What about filling the NULL fields with a "0" as SQLite starts autonumbering at 1 you can use "0" to represent no manager. You would then have to add the manager of ID 0 to your manager table, but at least all data should be returned.

Tigg

Josué Alba
02-04-2005, 01:05 PM
select d.department_name, e.first_name || e.last_name
from departments d, employees e
where e.employee_id = d.manager_id (+)

select d.department_name, e.first_name || ' ' || e.last_name
from departments d left outer join employees e
on ( e.employee_id = d.manager_id)

this was the code, many thanx.

Another question some one knows how is the Boyce Codd normalize form?

Intrigued
02-06-2005, 12:17 AM
Josué, I like your new avatar, by the way!

:yes