开发者

Search SQL query where this is true

开发者 https://www.devze.com 2023-02-03 11:06 出处:网络
I have a search query that works great, but I need it to only show results where visible = true. That\'s what needs to be added to the query, I just don\'t know how to do it correctly. Here\'s the que

I have a search query that works great, but I need it to only show results where visible = true. That's what needs to be added to the query, I just don't know how to do it correctly. Here's the query.

$query = $mysqli->query("SELECT id,name,company,town FROM people WHERE name LIKE '%$mysearchString%' OR company LIKE '%$mysearchString%' OR town LIKE '%$mysearchString%' ORDER BY name DESC LIMIT 100");

The开发者_运维百科 $mysearchString var is just a sanitized $_GET['s'].


SELECT id,name,company,town 
FROM people WHERE 
(name LIKE '%$mysearchString%' 
OR company LIKE '%$mysearchString%' 
OR town LIKE '%$mysearchString%')
 AND visible = true
ORDER BY name DESC LIMIT 100


$query = $mysqli->query("SELECT id,name,company,town FROM people WHERE (name LIKE '%$mysearchString%' OR company LIKE '%$mysearchString%' OR town LIKE '%$mysearchString%') AND visible = true ORDER BY name DESC LIMIT 100");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号