Alex Manzano Alex Manzano - 2 months ago 4
MySQL Question

My query fundamentally is wrong. Help, please

Is there a simple explanation why this query doesn't work, and what is its alternative?

SELECT * FROM items WHERE item_category = 'shirts' AND WHERE item_category = 'pants'

By the way, I have to keep the clause...


because I need all the data that is selected for later use.


Don't include WHERE twice:

SELECT * FROM items WHERE item_category = 'shirts' OR item_category = 'pants'

You also don't want to specify "AND", because there won't be a point where both item_category will be shirts and pants at the same time.