Q:

Count(id) in MySQL into a string

I have the SQL query:
$query = "SELECT yearoffiling, COUNT( id )
FROM files
GROUP BY yearoffiling
LIMIT 0 , 30";

How do I put the values from COUNT(id) inside a string?
Thank you.

A:

$query = "SELECT yearoffiling, COUNT( id ) total FROM files GROUP BY yearoffiling LIMIT 0 , 30";

$result = mysql_query($query);

while ($ary = mysql_fetch_assoc($result)){

    echo $ary['total'];

}

This is how I would do it "old school". I recommend using prepared statements and PDO these days. Hope this helps. 

A:

You can use either the convert() or cast() functions to do this.
SELECT cast(COUNT(id) as char), ....

A:

Jeremy, just to add to yours i think you may need the AS attribute to do the modifaction
$query = "SELECT yearoffiling, COUNT( id ) AS total FROM files GROUP BY yearoffiling LIMIT 0 , 30";

