您的位置:首页 > 其它

mybatis中if test 语句 当参数类型为string时,如何写判断条件

2020-02-02 22:00 489 查看
代码片段:
<select id="findPhonesById" parameterType="java.lang.String" resultType="java.lang.String">
select phone from contact_list cl left join contact_group cg on cl.d_id = cg.id
where 1 = 1
<if test="_parameter == 1">
and cl.d_id in (select distinct d_id from contact_list)
</if>
<if test="_parameter != 1">
and cl.d_id = #{id}
</if>
</select>

使用_parameter代替传入的参数,不会报错。

转载于:https://www.cnblogs.com/MIXP/p/7655591.html

  • 点赞
  • 收藏
  • 分享
  • 文章举报
diaoxi3657 发布了0 篇原创文章 · 获赞 0 · 访问量 379 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: