我是靠谱客的博主 要减肥冰淇淋,这篇文章主要介绍MyBatis动态拼接sql一、if标签二、foreach标签三、sql标签,现在分享给大家,希望可以做个参考。

一、if标签

<select id="selectByMoney" resultType="demo.entity.User">
select * from t_user
<where>
<if test="money != null and money != ''">
and money>1000
</if>
</where>
</select>

二、foreach标签

<select id="selectUserByIds" resultType="demo.entity.User">
select * from t_user
<where>
<foreach collection="ids" open="and id in(" item="id" separator="," close=")">
#{id}
</foreach>
</where>
</select>

三、sql标签

<sql id="sql_temp">
select id ,user_name, passwd, money from t_user
</sql>
<select id="login" resultType="demo.entity.User">
<include refid="sql_temp"></include> where user_name=#{userName} and passwd=#{passwd}
</select>

最后

以上就是要减肥冰淇淋最近收集整理的关于MyBatis动态拼接sql一、if标签二、foreach标签三、sql标签的全部内容,更多相关MyBatis动态拼接sql一、if标签二、foreach标签三、sql标签内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部