LearningCoder
02-24-2013, 06:34 AM
Good morning,
How can I modify my select query to count the number of rows?
Here is my query:
$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.
How can I modify my select query to count the number of rows?
Here is my query:
$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.