gpt4 book ai didi

php - 如何在 MySQL 查询中搜索多列?

转载 作者:行者123 更新时间:2023-11-29 19:47:31 25 4
gpt4 key购买 nike

如何搜索多列,此代码搜索单列,请自定义我的代码

$keywords= "search keywords";
$keywords= htmlspecialchars($keywords);
$keywords= mysqli_real_escape_string($con, $keywords);
$countSql_s = "SELECT *, MATCH(website) AGAINST ('%".$keywords."%') AS score FROM search WHERE MATCH(website) AGAINST ('%".$keywords."%') ORDER BY score DESC";

最佳答案

只需更改“WHERE”以包含对每列的检查,如下所示:

... WHERE MATCH(website) AGAINST('%".$keywords."%') > 5
AND MATCH(username) AGAINST('%".$keywords."%') > 5
...

关于php - 如何在 MySQL 查询中搜索多列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40902125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com