• 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)
    问题解决

  • 相关阅读:
    mongo常用查询
    MongoDB
    python连接mongo
    linux 硬盘
    kali 日志
    linux 命令
    grep
    linux shell
    linux 匹配字符串是否为数字
    linux 第一题 计算题
  • 原文地址:https://www.cnblogs.com/inspred/p/7551915.html
Copyright © 2020-2023  润新知