467,149 Members | 1,244 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,149 developers. It's quick & easy.

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

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
  • viewed: 3760
Share:
1 Reply
ck9663
Expert 2GB
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.

Similar topics

3 posts views Thread by Mike Cocker | last post: by
6 posts views Thread by Ljoha | last post: by
4 posts views Thread by C White | last post: by
11 posts views Thread by Andy_Khosravi@bcbsmn.com | last post: by
1 post views Thread by NewUser | last post: by
5 posts views Thread by Sam | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.