一个条件list mysql中可以直接使用in,list中多个条件同时满足查询list时就不能直接用in了
比如我想根据list中的四个条件(name、materialCategoryBrandId、model、unitId)查询出表中这两条数据
这时使用mysql中间表连接查询sql如下:
select b.*
from
(
-- <if test="query != null and query.size > 0">
-- <foreach collection="query" item="item" separator=" union all " >
-- select #{item.name} name, #{item.materialCategoryBrandId} materialCategoryBrandId, #{item.model} model, #{item.unitId} unitId from dual
-- </foreach>
-- </if>
select '六类跳线' name, 658250366200262656 materialCategoryBrandId, '2米' model, 18 unitId from dual
union all
select '六类4对UTP电缆' name, 65825