Echoing a pseudo column value after a COUNT
Posted
by rob - not a robber
on Stack Overflow
See other posts from Stack Overflow
or by rob - not a robber
Published on 2010-06-18T01:09:43Z
Indexed on
2010/06/18
1:13 UTC
Read the original article
Hit count: 257
Hi Gang...
Please don't beat me if this is elementary. I searched and found disjointed stuff relating to pseudo columns. Nothing spot on about what I need.
Anyway... I have a table with some rows. Each record has a unique ID, an ID that relates to another entity and finally a comment that relates to that last entity.
So, I want to COUNT these rows to basically find what entity has the most comments.
Instead of me explaining the query, I'll print it
SELECT entity_id, COUNT(*) AS amount FROM comments GROUP BY entity_id ORDER BY amount DESC
The query does just what I want, but I want to echo the values from that pseudo column, 'amount'
Can it be done, or should I use another method like mysql_num_rows?
Thank you!!!
© Stack Overflow or respective owner