elephpant 2021-07-28 16:40 采纳率: 76.2%
浏览 23
已结题

使用mybatis sql查询,使用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

  • 写回答

1条回答 默认 最新

  • 懒猫-DustFree 2021-07-28 17:09
    关注

    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}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 12月23日
  • 已采纳回答 12月15日
  • 创建了问题 7月28日