MyBatis常用几种模糊查询的写法

来源:互联网 发布:淘宝加热棒 编辑:程序博客网 时间:2024/06/05 02:10

1.sql中字符串拼接

   select * from t_user WHERE user_name LIKE CONCAT(concat('%', #{test}),'%');

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

  select * from t_user WHERE user_name LIKE '%${text}%';

3.大小写匹配查询

   select *  from t_user WHERE UPPER(SUBSYSTEM) LIKE '%' || UPPER('ah') || '%'

或者

   SELECT *  FROMTABLENAME  WHERE LOWER(SUBSYSTEM) LIKE '%' ||LOWER('ah') || '%'
原创粉丝点击