I'm working on a new project, and for this project I need a "search Engine" of shops stored in my database. I make a Like query on the name and the address of the shop, but only where the shop is valid (set to 1). My query looks like that :
SELECT *
FROM (`shops`)
WHERE `shop_valid` = 1
AND `shop_address` LIKE '%lyon%'
OR `shop_name` LIKE '%lyon%'
ORDER BY `shop_offer` desc
LIMIT 5
The results returned by this query are correct with the name and the address, but some of them have the "shop_valid" is set 0. And when I remove for example the clause on the shop address, the query works well with all "shop_valid" set to 1. Like this :
SELECT *
FROM (`shops`)
WHERE `shop_valid` = 1
AND `shop_name`
LIKE '%lyon%'
ORDER BY `shop_offer` desc
LIMIT 10
Hope someone can help me, I'm being stuck for a while…
Thank you!