Hi Zoran,
Try moving the status criteria for UserCats to the LEFT OUTER JOIN
instead of the WHERE:
SELECT *
FROM Users as U LEFT OUTER JOIN
UserCat as UC on U.user_id = UC.user_id AND UC.status = 1
WHERE U.status = 1
Keeping UC.status in the WHERE clause would filter records from
I tried that but that's not what I need.
If I had three users (U1, U2, U3).
And their status = 1.
They each have three children UserCats U1C1, U1C2, U1C3, U2 C1, U2C2 , ...,
U3C3
All of U1 usercats have status = 1, U2 has 1 usercat status = 1 and U3 has
none,
I want to get a table like
User_id,
And this simple statement ?
SELECT * FROM Users as U
left outer join UserCat as UC on U.user_id = UC.user_id
WHERE U.status = 1
AND UC.status = 1
Zoran Avtarovski a écrit :
I have a parent:child table relationship using a Join SQL statement and I am
having trouble getting it right. One parent