Sep 13, 2018

Example of HAS ALL query in SQL

"GROUP BY ... HAVING COUNT" can use to find those emails which have all the tags you search for.

You have all the email_tag ids in tagids, the size of tagids is tagsize.

The example JPQL query is:
select e from EmailTagMap etm join e where in :tagids 
group by having count(distinct = :tagsize