zoukankan      html  css  js  c++  java
  • mysql查询优化

    一.模糊查询优化
    1.like
    like '%${name}%'       
    缺点:输入 % 或 _ 时,全部查出来
    2.concat
    SELECT * FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}), '%');

    ( 实际代码:  num LIKE CONCAT('%',#{request.num},'%')实际代码 )
    或: concat('%',keyword,'%')
    或:<if test="name !=null and name != '' ">
       and name like '%' ||#{name}|| '%'
    </if>
    缺点:%的问题解决了,但是输入下划线(_)时,全部查出来
    3.position
    select * from articles where POSITION('张三' in title)
    问题解决

  • 相关阅读:
    Django模板系统
    __new__与__init__的区别
    django中models field详解
    快速入门mysql
    jq2
    jq
    前端 js 部分
    前端 js
    前端 css
    前端 table form
  • 原文地址:https://www.cnblogs.com/inspred/p/7551915.html
Copyright © 2011-2022 走看看