<select id="mapper中的方法名" resultType="返回类型">
select
t.id as id,
t.user_name as username,
t.age as age
from
user t
<where>
<!-- choose when 可以不加,我这里是业务需要 -->
<choose>
<when test="list != null and list.size() > 0">
<!-- 集合不为空时,遍历,下方sepatator中的or,是因为业务需要,你可以根据自己的需求选择分隔符 -->
<foreach collection="list" item="item" index="index" open="(" separator="or" close=")">
(
t.user_name = REGEXP_SUBSTR(#{item}, '[^-]+', 1, 1)
and t.age= REGEXP_SUBSTR(#{item}, '[^-]+', 1, 2)
)
<foreach>
</when>
<otherwise>
Java Oracle动态sql字符串切割 split函数类似功能实现
最新推荐文章于 2024-04-03 16:13:15 发布