View Single Post
Old 02-24-2013, 06:34 AM   PM User | #1
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
Counting number of rows

Good morning,

How can I modify my select query to count the number of rows?

Here is my query:
PHP Code:
$sql 'SELECT username, DATE_FORMAT(join_date, "%d/%m/%y") AS join_date_str
         FROM users
         ORDER BY join_date 
         DESC
         LIMIT 5'

I've tried adding COUNT(id); but it only returns 1 row and it overwrites the username. It does count the number of rows correctly though.

I've looked on mysql reference and googled but can't seem to find the answer I am looking for!

Regards,

LC.
LearningCoder is offline   Reply With Quote