This is probably very simple, like most of my questions but I can't narrow my search on the web.
I've two tables
Users and UserGroups; Users store information about users, Usergroups store groups subscribed to by each user; primary/referential key between them is userID; this is a one to many relationship with each user allowed to have more than one usergroup.
I'm trying to find a query in MySQL 3.x that will give me all the users who subscribe to two groups.
As a start I can do:
Select * From Users, UserGroups WHERE Users.userID = UserGroups.userID WHERE UserGroups.groups = "GROUPA" OR UserGroups.groups = "GROUPB";
This will give me anyone who is subscribed to either group, from this I could just work out those who have a name that appears twice, but surely there's a better way?
I've two tables
Users and UserGroups; Users store information about users, Usergroups store groups subscribed to by each user; primary/referential key between them is userID; this is a one to many relationship with each user allowed to have more than one usergroup.
I'm trying to find a query in MySQL 3.x that will give me all the users who subscribe to two groups.
As a start I can do:
Select * From Users, UserGroups WHERE Users.userID = UserGroups.userID WHERE UserGroups.groups = "GROUPA" OR UserGroups.groups = "GROUPB";
This will give me anyone who is subscribed to either group, from this I could just work out those who have a name that appears twice, but surely there's a better way?