douwei2966 2015-08-02 23:05
浏览 591

REGEXP具有多个字段和条件

Instead of searching through a single column for query, I would like my Regexp query to refer to several columns in determining the results of a search as well as limit the the extend of its search activity per session the search function is executed ( so for instance, on the first session the search will only look for the first 10, while if the search is prompted a second time then the next 10 will be sought for). The reason for this limited extend is to prevent latency issues in the long run if the database grows.

I am wanting to do this for a camp roster, where non-fixed keywords will determine the group members of registered campers based on searching through two columns: hobbies and spirit_animal_explanation for words matching the keywords.

PHP:

$searchCD = "SELECT * FROM users WHERE hobbies AND spirit_animal_explanation REGEXP '".$keywords."' LIMIT 10";
$searchST = $con->query($searchCD);

if ($searchST) {
while ($row = $searchST->fetch_assoc()) {

  echo $row["first_name"]. "<br/>" . "<br/>" . $row["hobbies"] . "<br/>" . $row["spirit_animal_explanation"] .
  "<br/>" . $row["avatar"] . "<br/><br/>"  ;

}

}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试,帮帮忙吧
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建