Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010
    Posts
    3

    Question Unanswered: Count the number of items for a query

    I'm trying to output how many bands I have for a genre starting with a certain letter using this query

    SELECT p.title AS title, g.letter AS letter, g.url AS url
    FROM band AS g, genre AS p
    WHERE g.genre = p.id AND p.url='" . $clean['genre'] . "'"


    However I'm getting
    HTML Code:
    0-9 ()
    0-9 ()
    0-9 ()
    0-9 ()
    B ()
    B ()
    B ()
    ...
    and instead it should be
    HTML Code:
    0-9 (4)
    B(3)
    ...
    Bands table:
    id title band url letter

    Genre table:
    id title url count
    Last edited by s0me0ne; 01-10-10 at 16:32.

  2. #2
    Join Date
    Jan 2010
    Posts
    3
    I figured it out, I needed to add " GROUP by g.letter" to the end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •