If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

I also tried putting it before the username field but it seems to overwrite my username field and it only prints one row of data. When I take it out I have my desired result. I need to count how many users there are so I can print out the result on another part of my page.

Oh. Yeah. once you toss in a COUNT, it aggregates everything into a single row. The solution would be to add a GROUP BY clause...or actually that will probably not give you the correct row count. You'll either need to use a subquery, or join the table on itself.

This isn't exactly elegant (i'd prefer multiple SQL queries) but...

Code:

SELECT username, DATE_FORMAT(join_date, "%d/%m/%y") as join_date_str,
(SELECT COUNT(*) FROM users) AS num_users
FROM users
ORDER BY join_date
DESC
LIMIT 5;