gpt4 book ai didi

java - mybatis中String和params的连接

转载 作者:可可西里 更新时间:2023-11-01 08:11:25 25 4
gpt4 key购买 nike

我已经搜索过这个,+$ 将不起作用。我不想在 mybatis 选择查询中将 %#search 参数连接起来。我想在 mybatis XML 配置中实现这一点,而不是服务(Java)...

我有这个问题

<select id="carriersDataTable" parameterType="map" resultType = "carrier">
SELECT
carrierId
name,
prefix,
country,
status,
isdirect as direct
FROM carriers
WHERE name LIKE '%' + #{search} + '%' AND Status != -1 AND IF(''=#{status}, 1, Status = #{status})
ORDER BY name
LIMIT #{startIndex}, #{fetchSize}
</select>

我试过 LIKE '%' + #{search} + '%'LIKE ${%#{search}%} 都行不通

最佳答案

试试数据库中内置的字符串连接函数,例如

LIKE CONCAT('%', #{search}, '%')

对于 MySQL

关于java - mybatis中String和params的连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32645859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com