If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Count the number of items for a query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-10, 14:57
s0me0ne s0me0ne is offline
Registered User
 
Join Date: Jan 2010
Posts: 3
Question 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 15:32.
Reply With Quote
  #2 (permalink)  
Old 01-10-10, 15:50
s0me0ne s0me0ne is offline
Registered User
 
Join Date: Jan 2010
Posts: 3
I figured it out, I needed to add " GROUP by g.letter" to the end
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On