I have two tables in a database of different product brands that I'm trying to get a count of so that it combines the count of both given the description search. What I have so far is this:
$pages_query = mysql_query ("SELECT COUNT('Product Number') FROM brand1 WHERE description LIKE '%oven%' UNION ALL SELECT COUNT('Product Number') FROM brand2 WHERE description LIKE '%oven%'") ;
When I echo this, it spits out 60, which is the result for brand1 table only and does not add the count from the brand2 table (which I thought UNION ALL was supposed to do or do I have that incorrect?) The end number should be 173 because the other table has 113 results that match this query.
Which would be the best way to add the count results into one number?
Thanks.
productsinto a single table withbrandas a column. Your query would then beSELECT COUNT(*) FROM products WHERE description LIKE '%oven%' AND brand IN ('brand1', 'brand2');- much simpler and more elegant solution