I am searching for an SQL command to combine several many-to-many queries.
At the end I only want to get results suitable for all restrictions.
Better show you my tables:
The query I am searching for should only process USERs that have ROLE 1 and
2 AND furthermore have GROUPs 1 and 2 at the same time. How to chain these
restrictions into ONE SQL-query?
What would the query look like?
The following query would only get me all USERs having ROLE 1:
SELECT * FROM USER WHERE id IN (SELECT DISTINCT USER_ROLE.user_id FROM
USER_ROLE WHERE USER_ROLE.role_id = 1);
Thanks in advance!
I really need help with this! Thanks again.
View this message in context:
Sent from the MySQL - General mailing list archive at Nabble.com.