I have many queries, can I combine it into 1 to optimize?
SELECT COUNT(prod_id) FROM products WHERE inventory <= 5 AND cat_id = 1SELECT COUNT(prod_id) FROM products WHERE inventory BETWEEN 5 AND 10 AND cat_id = 1SELECT COUNT(prod_id) FROM products WHERE inventory > 10
I think this should work for you. It will return the 3 counts in a single SQL statement:
And here is the SQL Fiddle.
Good luck.