OK, i've got the following 3 tables:
users
userID
name
...
groups
groupID
group_name
...
usersingroups
userID
groupID
What I want to do is SELECT * FROM groups where userid 1 does not have a corresponding record in the usersingroups table. Sorry, I know that's not very good english, but hopefully you understand what I'm trying to say. I can't even say it properly in english, so I don't know how to put it into SQL!!
Also, I used something similar to the following to get out the groups the user is a member of. It works, but I just wondered if it wasn considered bad programming practice, using left join on left join:
SELECT * FROM groups LEFT JOIN usersingroups using (groupID) LEFT JOIN users using (userID) where users.userID = 1;
Can somebody tell me if that's OK, or if I should have done it differently?
users
userID
name
...
groups
groupID
group_name
...
usersingroups
userID
groupID
What I want to do is SELECT * FROM groups where userid 1 does not have a corresponding record in the usersingroups table. Sorry, I know that's not very good english, but hopefully you understand what I'm trying to say. I can't even say it properly in english, so I don't know how to put it into SQL!!
Also, I used something similar to the following to get out the groups the user is a member of. It works, but I just wondered if it wasn considered bad programming practice, using left join on left join:
SELECT * FROM groups LEFT JOIN usersingroups using (groupID) LEFT JOIN users using (userID) where users.userID = 1;
Can somebody tell me if that's OK, or if I should have done it differently?