dimanche 5 juillet 2015

How to construct query which compares two sets in M:N relationship?

I have two (three-the third is the binding table) tables User and Feature. They are in many-to-many relationship. I would like to construct query which finds all the users which have similar features as the particular user.

I know that normally I can use something like this:

select user from User user 
inner join user.feature feature
where feature in :features

But this works only when I am looking just for one specific feature. Is there a way how to do it in a way of comparing "two sets" "features in features" in SQL? Or do I have to do it in business layer?

Aucun commentaire:

Enregistrer un commentaire