I have to tables:
1) USERS with all emails and ids
2) USER_RELATIONS with the relations that tell me in which category the user is.
1 USER can be in MORE THEN 1 CATEGORY.
I made this select statement to take all users subscribed to cat 4 OR 7, but I get some users 2 times... I want to get the users who are subscribed to both cats only 1 time.
WHAT'S WRONG?
SELECT users.email FROM users LEFT JOIN users_relations ON users.id = users_relations.user_id WHERE 1=1 AND (users_relations.id_cat=4 OR users_relations.id_cat=7);