doubi6669 2013-07-24 12:53
浏览 6

对于这个MYSQL搜索查询,还有其他更快的执行方法吗?

I have 100K datas in my mysql database, I want to search a query in it. I removed stop-words and splitted it into an array of keywords and stored in a variable ie $key[0],$key[1],$key[2].I am using the following query

SELECT * 
FROM   `table` 
WHERE (`column` LIKE '%$key1%' 
     OR `column` LIKE '%$key2%' 
     OR `column` LIKE '%$key3%');

is any other faster ways to do the same.

  • 写回答

3条回答 默认 最新

  • drhwb470572 2013-07-24 12:57
    关注

    you can do something like this

    SELECT * 
    FROM  table 
    WHERE colomn REGEXP '$key1|$key2|$key3' 
    

    etc etc so instead of creating your array as a comma separated list of key words do it as a pipe separated list and then just push the string into your regex too this is simply an example

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用