使用场景,in适合数据量小的时候,exists适合数据量大的时候。
<if test="torqueRecordPageDTO.vinList != null and torqueRecordPageDTO.vinList.size >0">and exists (select 1 from (<foreach collection="torqueRecordPageDTO.vinList" item="item" index="index" separator="union all">select #{item} as vinfrom dual</foreach>) a where a.vin = f.record_vin and a.product_id = t1.product_id)</if> <!-- <if test="torqueRecordPageDTO.vinList != null and torqueRecordPageDTO.vinList.size >0">--> <!-- AND F.record_vin in--> <!-- <foreach collection="torqueRecordPageDTO.vinList" separator="," item="v" open="(" close=")">--> <!-- #{v}--> <!-- </foreach>--> <!-- </if>-->
原文地址:https://blog.csdn.net/weixin_43763459/article/details/121422693