Alex Manzano Alex Manzano - 1 year ago 86
MySQL Question

How to debug a failing SELECT statement?

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'

I have to keep the clause:


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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download