I've three tables:
1) project: ID,Name,Desc
2) user: ID,Name,user,pwd...
3) user2proj:ID,PrjID,UsrID,Allowed
I want join 1 with 3 where UsrID is the logged user.
SELECT p.ID,p.Name,p.Desc,u.Allowed
FROM project p, user2proj u
WHERE u.UsrID=$logusr.
Now the problem: the table 3 maybe empty for a user!
So I've tried with:
SELECT p.*, u.Allowed
FROM project p LEFT JOIN user2proj u ON p.ID=u.PrjID
WHERE (u.UsrID=$logusr OR u.ID IS NULL)
But this don't give me all projects where exist u.ID but for another user!
What can I do? Have I to use two distinct query?
Please give me any hint...