Je pense que cette requête pourrait vous aider :
SET @tag1 = 1, @tag2 = 4; -- Setting some user variables to see where the ids go. (you can put the values in the query)
SELECT wtagrels.id_wc,
SUM(DISTINCT( wtagrels.id_tag [email protected] OR wtagrels.id_tutor [email protected])) AS key_1_total_matches,
SUM(DISTINCT( wtagrels.id_tag [email protected] OR wtagrels.id_tutor [email protected])) AS key_2_total_matches
FROM all_tag_relations AS wtagrels
WHERE ( wtagrels.id_tag [email protected] OR wtagrels.id_tag [email protected] )
GROUP BY wtagrels.id_wc
HAVING key_1_total_matches = 1 AND key_2_total_matches = 1
LIMIT 0, 20
Il renvoie id_wc = 1
.
Pour (6, 3) la requête ne renvoie rien.