By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,766 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,766 IT Pros & Developers. It's quick & easy.

Query to display Count as zero if no records exists - Urgent please

P: 17
Count should be displayed as zero if there is are no recipes posted

select f.dishes,f.contentid,f.titleurl,count(f.dishes) as Recipescount from food f inner join foodmemberpref fmp
on f.contentid=fmp.foodid where isapproved=1 and blogcid>0
and f.contentid in(1,30,68,73,83)
group by f.dishes, f.contentid,f.titleurl

When I execute the above query I get the result displayed as given below

Dishname Contentid Titleurl Recipescnt
Aloo Chat 1 punjabi/aloo-chat 1
Payasam 30 south-indian/payasam 5
Aloo Tikki 68 punjabi/aloo-tikki 7



I want the Output to be displayed as. I want to display even those dishes count for which the count is zero, in other words it should display the count of all dishes even if it is zero

Dishname Contentid Titleurl Recipescnt
Aloo Chat 1 punjabi/aloo-chat 1
Payasam 30 south-indian/payasam 5
Aloo Tikki 68 punjabi/aloo-tikki 7
Carrot Kheer 73 north-indian/carrot-kheer 0
Coconut Rice 83 south-indian/coconut-rice 0
Sep 23 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
Use LEFT JOIN instead of INNER.

-- CK
Sep 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.