In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
小编给大家分享一下Mybatis怎么解决sql中like通配符模糊匹配问题,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
sql中like通配符模糊匹配问题
针对oracle数据库:
将查询条件通过功能类处理/** * Description: 处理转义字符%和_,针对ORACLE数据库 * * @param str * @return */ public static String escapeStr(String str) { String temp = ""; for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == '%' || str.charAt(i) == '_') { temp += "\\" + str.charAt(i); } else { temp += str.charAt(i); } } return temp; }后台Contronller获得查询条件
并调用工具类处理
String areaname = request.getParameter("Areaname"); if (areaname != null) { if ("".equals(areaname)) { areaname = null; } else { areaname = StringUtils.escapeStr(areaname); } }mapper.xml中对应的使用方法 and areaname like '%'||#{param.areaname}||'%' escape '\'使用like实现模糊匹配方式一select * from t_user where name like ' %${value}% '方式二select * from t_user where name like '%'||${value}||'%'方式三select * from t_user where name like #{do_it_in_java}以上是"Mybatis怎么解决sql中like通配符模糊匹配问题"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.