开发者

Search SQL query where this is true

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜