milosman
Grasshopper
Points: 23
More actions
November 17, 2005 at 5:07 am
#169494
I have two tables. tbl_user and tbl_visits. In tbl_user are all the users and tbl_visit stores one new row for every visit to my site. I want to get the following in ONE sql-statement.
userID - username - numberOfVisits
1 - Carl - 13
2 - John - 14
3 - Mary - 2
4 - Carl - 4
5 - Carl - 8
Any ideas?
Paula-129590
SSC-Addicted
Points: 437
November 17, 2005 at 5:24 am
#604388
Try...
select tbl_user.userID, tbl_user.username, count(tbl_visit.numerOfVisits)
from tbl_user, tbl_visit
where tbl_user.userID = tbl_visit.userID
group by tbl_user.userID, tbl_user.username
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply