please help iam lost with this :(

Discussion in 'Databases' started by ezguy, Sep 1, 2007.

  1. #1
    hi guys

    I have a custom forum

    i have a users table


    which has userid

    userstable
    -----------------
    userid , name
    1 , 'hhh'
    2 , 'hhhj'
    3 , 'mmm'


    in another table

    forumpost
    -------------------
    userid , forumcontent
    1 , 'xyz'
    1, 'ddd'
    2, 'ff'
    1, 'jj'



    i want a query which will return the top users who posted the most content

    is there any query like that which return that
     
    ezguy, Sep 1, 2007 IP
  2. webw

    webw Peon

    Messages:
    32
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:

    SELECT userid, COUNT(*) AS hits FROM `forumpost` GROUP BY userid ORDER BY hits DESC
    Code (markup):
     
    webw, Sep 1, 2007 IP
  3. ezguy

    ezguy Well-Known Member

    Messages:
    1,184
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    128
    #3
    well there are two tables not one
     
    ezguy, Sep 1, 2007 IP
  4. ezguy

    ezguy Well-Known Member

    Messages:
    1,184
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    128
    #4
    it works fine thanks a lot :)
     
    ezguy, Sep 1, 2007 IP