工作中用到,写三种用法吧,第四种为大小写匹配查询

 

1. sql中字符串拼接

   SELECT * FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}), '%');

 

2. 使用 ${...} 代替 #{...}

   SELECT * FROM tableName WHERE name LIKE '%${text}%';

 

3. 程序中拼接

   Java

   // String searchText = "%" + text + "%";

   String searchText = new StringBuilder("%").append(text).append("%").toString();

   parameterMap.put("text", searchText);

 

   SqlMap.xml

   SELECT * FROM tableName WHERE name LIKE #{text};

 

4. 大小写匹配查询

   SELECT *  FROM TABLENAME  WHERE UPPER(SUBSYSTEM) LIKE '%' || UPPER('jz') || '%'

   或者 

   SELECT *   FROM TABLENAME  WHERE LOWER(SUBSYSTEM) LIKE '%' || LOWER('jz') || '%'


 

原帖地址:http://blog.csdn.net/luqin1988/article/details/7865643

相关文章:

  • 2021-08-04
  • 2021-06-29
  • 2022-12-23
  • 2021-10-28
  • 2021-08-15
  • 2021-10-16
猜你喜欢
  • 2021-07-17
  • 2021-10-07
  • 2021-10-23
  • 2022-01-21
相关资源
相似解决方案