select value
from tablename
WHERE one_level in(1,1,1,1)
and two_level in(1,1,1,1)
and three_level in(0,1,2,3)
and save_time='2021-07-25 09:00:00'
如何使用mybatis查询上面的sql
select value
from tablename
WHERE one_level in(1,1,1,1)
and two_level in(1,1,1,1)
and three_level in(0,1,2,3)
and save_time='2021-07-25 09:00:00'
如何使用mybatis查询上面的sql
Mapper接口定义一个方法
List<String> selectValue(@Param("oneLevels") List<Long> oneLevels, @Param("twoLevels") List<Long> twoLevels, @Param("threeLevels") List<Long> threeLevels, @Param("savaTime") Date savaTime);
XML 里面SQL可以这样写
select value from tablename
WHERE one_level in
<foreach collection="oneLevels" item="oneLevel" separator="," open="(" close=")">
#{onLevel}
</foreach>
and two_level in
<foreach collection="twoLevels" item="twoLevel" separator="," open="(" close=")">
#{twoLevel}
</foreach>
and three_level in
<foreach collection="threeLevels" item="threeLevel" separator="," open="(" close=")">
#{threeLevel}
</foreach>
and save_time= #{saveTime}