当前位置:Gxlcms > 数据库问题 > mybatis中的模糊查询,Oracle和MySQL中的concat

mybatis中的模糊查询,Oracle和MySQL中的concat

时间:2021-07-01 10:21:17 帮助过:5人阅读

MySQL数据库,利用concat函数即可,MySQL不用能||连接字符串

mapper.xml

  select * from tb_content_category where title like concat(‘%‘,#{paramMap.TITLE, jdbcType=VARCHAR},‘%‘)

 

Oracle数据库,利用concat函数或者||,Oracle数据库利用concat函数时,需要嵌套concat,因为Oracle的concat函数每次只能连接两个字符串

mapper.xml

  select user_account, full_name from tm_user where full_name like ‘%‘||#{paramMap.TITLE, jdbcType=VARCHAR}||‘%‘
或者
  select user_account, full_name from tm_user where full_name like concat(concat(‘%‘,#{paramMap.TITLE, jdbcType=VARCHAR}),‘%‘)

 

或者直接在传入参数时,将需要模糊查询的参数前后加上%

 

mybatis中的模糊查询,Oracle和MySQL中的concat

标签:连接字符串   char   bat   HERE   type   name   param   直接   oracl   

人气教程排行