I have a table containing information about retail stores. I have a list of retail chain names (WalMart, Target, Eatons, etc...) When the user selects one I basically run a query to find anything having to do with that chain.
SELECT * FROM stores WHERE store_name LIKE '%$chain%' ORDER BY store_name ASC
For example, if the user selects 'WalMart', the query would return anything with the word 'WalMart' in it's name (WalMart Scarborough, WalMart Supercenter Toronto, WalMart Distribution Center etc...).
But now I would like to give the user the ability to search through this list via a search text box. The way I usually do searches is like so:
SELECT * FROM stores WHERE store_name LIKE '%$user_input%' ORDER BY store_name ASC
But in this case the query will return ALL stores containing the user_input, not just WalMarts. If I type in Toronto I would like to see WalMart Supercenter Toronto, but will of course get Target Toronto etc....
How can I make it so that I'm looking for anything containing the user_input but also only within the WalMart subset. I would like to do this in a single query if possible. Can I use two LIKE statements like this?
Sorry, haven't tried anything yet as I'm not sure where to start.