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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • padmaneha
    New Member
    • Sep 2008
    • 17

    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.cont entid,f.titleur l,count(f.dishe s) 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,8 3)
    group by f.dishes, f.contentid,f.t itleurl

    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
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Use LEFT JOIN instead of INNER.

    -- CK

    Comment

    Working...