如何满足sql中一个字段满足多个条件

863 阅读1分钟

1、直接上sql,首先将满足多个条件的sql同时查询出来,然后根据查询的字段进行分组,通过分组个数筛选符合条件的结果,目前没想到有什么漏洞,望指教

select
       distinct id
 from tableA
 where  id in
     (select id
     from tableA
     where
         <foreach collection="list" close=")" open="(" item="item" separator="or">
             id = #{item}
         </foreach>
     group by id
     having count(id) = #{count})