Forum Moderators: coopster

Message Too Old, No Replies

Count query in mysql query?

         

Twisted Mind

2:54 pm on Feb 16, 2006 (gmt 0)

10+ Year Member



Is it possible to retreave all data from 1 table.. and count a number of records where 1 row has the same number as id of the main table?

example

Table categories
id name
1 blah
2 hello

Table Threads
id name categoryid
1 first 1
2 mid 2
3 noon 1
4 blah 1
5 roar 2

Result of query should become
id name categoryid
1 blah 3
2 hello 2

I dont really believe this is possible but if it is please tell me :D

omoutop

3:03 pm on Feb 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you try using a JOIN on sql query? Something like....

SELECT COUNT(*) AS $test FROM ..... WHERE .... JOIN ....

I think this would work

Twisted Mind

3:25 pm on Feb 16, 2006 (gmt 0)

10+ Year Member



i dind but i made a count query in the while already is nice too :p