SELECT count(Recipe_ID) FROM Recipes WHERE softdiet = 'TRUE';
SELECT count(Recipe_ID) FROM Recipes WHERE mediumdiet = 'TRUE';
SELECT count(Recipe_ID) FROM Recipes WHERE harddiet = 'TRUE';
but I like to learn more about MYSQL. Is there a way to put above 3 queries into 1 getting either 3 rows with the count values or 1 row with all 3 values.
Last edited by AGISB on Tue Jan 11, 2005 9:45 am, edited 1 time in total.
SELECT COUNT(Recipe_ID) FROM Recipes WHERE softdiet = 'TRUE'
UNION SELECT COUNT(Recipe_ID) FROM Recipes WHERE mediumdiet = 'TRUE'
UNION SELECT COUNT(Recipe_ID) FROM Recipes WHERE harddiet = 'TRUE'
select
sum(softdiet = 'TRUE') as soft_cnt,
sum(mediumdiet = 'TRUE') as medium_cnt,
sum(harddiet = 'TRUE') as hard_cnt
from Recipes
where 'TRUE' in (softdiet, mediumdiet, harddiet)