Correct syntax to narrow down SELECT query

Quick simple syntax question

I have table and I use a query to show all items in a specific category.

$query="SELECT * FROM shop WHERE mcat='Washing & Laundry';

I want to narrow it down further.

So, I’d only like to include items in the results that have ‘washing machine’ in the ‘name’ field.

I can seem to get it right.

So I’m guessing you want all results in the Washing & Laundry category where Washing machine is in the name field. If this is the case you can simply add the AND keyword to narrow it down further

$query="SELECT * FROM shop WHERE mcat='Washing & Laundry' AND name='washing machine'";

Hope that helps.

Thanks but.

That doesn’t display any results because the ‘name’ field holds name like…

Indesit SIXL145 washing machines in White / Black

Got it

$query="SELECT * FROM shop WHERE mcat='Washing & Laundry' AND name like '%washing machine%'";

take care of the case sensitivity of the value in the field “name”. If it defined something like latin1_swedish_ci, means “case-insensitive” then no problem
otherwise you will have to handle the collation in your query/db.