Number of visitors

  • 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?

  • 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