< if test = "set != null and set.size != 0" > select v.userName FROM < foreach collection = "userList" item = "item" separator = "union" open = "(" close = ")" > select #{item} as userName </ foreach > v where v.userName not IN (select xx from table where xxxx='****') </ where >
  • table:表名
  • xxxx='****':条件,这里可以是
  • <where>
       <if test="set != null and set.size != 0">
           select v.userName FROM
           <foreach collection="userList" item="item" separator="union" open="(" close=")">
               select #{item} as userName
           </foreach>
           v where v.userName not IN (select name from user where age>20);
    </where>
    

    chaohenwww.yuque.com/heioky