SQL count display distinct query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madmod001
    New Member
    • May 2010
    • 1

    SQL count display distinct query

    Hi there,
    Im wondering if any one can help with if possible a single SQL query

    what i am trying to achieve is a count on the rows [name] only on active entries while also displaying only the single name.

    Table

    id name active
    1 dog 1
    2 dog 1
    3 cat 1
    4 frog 1
    5 cat 0
    6 dog 1
    7 cat 1

    results should look like this

    dog 3
    cat 2
    frog 1

    I have done this in other database programs but have not been able to achieve the same results with PHP and MySQL
    Any Help would gratefully be received :-)
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    it looks like a combination of COUNT() and WHERE, maybe requiring a JOIN, but the people at the MySQL forum should know more than me.

    Comment

    Working...