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 etm.email e where etm.emailTag.id in :tagids 
group by e.id having count(distinct etm.emailTag.id) = :tagsize