views:

71

answers:

2

I have a table with my products and I'm trying to write a page that would pull bracelets with certain colors from the database. So here's what I have right now (in php):

$query = "SELECT * FROM products WHERE (products.colors LIKE '%black%')";

But I only want to select rows where the value for the column "category" equals "bracelet".

I've tried a few different things, but I keep getting warnings and errors. I appreciate any help you can give, thank you!

+9  A: 
$query = "SELECT * FROM products WHERE products.colors LIKE '%black%' AND products.category = 'bracelet'";

There you go.

Conspicuous Compiler
Thank you! I knew it had to be something simple, but for some reason I couldn't find it with all my mad Googling.
KeriLynn
+5  A: 

You can do:

SELECT * FROM products 
WHERE colors LIKE '%black%' 
AND category = 'bracelet'
codaddict
Thank you very much!
KeriLynn