My user group system has a table with these fields: user_id - group_id
So a user can have multiple groups, one for each row.
What I want to do, is pull records where they have a group_id of say "6" but not where they also have a group_id row where the value is "9".
I tried this:
SELECT u.`username` FROM `users` u INNER JOIN `user_group_membership` g ON u.user_id = g.user_id WHERE g.group_id != 9 AND g.group_id = 6 ORDER BY u.`username` ASC
However, that doesn't work, it still pulls in users who have a group_id that = 9.