I got a problem in the query when I tried to select more data by joining the son and father table with a work table like so:
Code:
select son.ID
, son.First_Name
, son.Last_Name
, son.Father_ID
, son.Mother_ID
, work.BossName
from people as son
, work
where son.First_Name = 'John' AND
work.employeeID = son.ID
union
select dad.ID
, dad.First_Name
, dad.Last_Name
, dad.Father_ID
, dad.Mother_ID
, work.BossName
from people as son
, work
left outer
join people as dad
on son.Father_ID = dad.ID
where son.First_Name = 'John' AND
work.employeeID = dad.ID;
I am getting the same incorrect BossName for the sons. The bossname I am getting belongs to one of the sons, but it gets repeated to all of them...
what is wrong?
Bookmarks