Help with MySQL simple query

Discussion in 'MySQL' started by eddiemoth, Dec 7, 2008.

  1. #1
    Hi folks,
    New to MySQL. I just want to be able to run a query to find user who has posted X numbers start from X date.

    In example below I can get all users who have posted 2000 posts or more. Can I use a system date to limit only to those who has posted 2000 posts from January 01, 2008. There is no date field on the table. Any suggestions or hints are appreciated.

    SELECT *
    FROM cms_users
    WHERE user_posts >= '2000'
     
    eddiemoth, Dec 7, 2008 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    if there isn't any date field that's not good - can't make it to filter date if there is no date sorry
     
    crivion, Dec 8, 2008 IP
  3. VishalVasani

    VishalVasani Peon

    Messages:
    560
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello,

    Do you have any other associating table where you can get them filter out on date ?
     
    VishalVasani, Dec 8, 2008 IP
  4. ColorWP.com

    ColorWP.com Notable Member

    Messages:
    3,121
    Likes Received:
    100
    Best Answers:
    1
    Trophy Points:
    270
    #4
    If you mean to order the entries by the time they were added to the MYSQL DB (for example, user posts = DB entry created/updated = MYSQL timestamp placed), then this is not possible, because MYSQL does not write down by default when an entry is created/updated. That's why people usually make another column for the "date posted". Then get the entries and order them by that date column.
     
    ColorWP.com, Dec 8, 2008 IP
  5. eddiemoth

    eddiemoth Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you all for checking. I saw another table called cms_bbposts which has a field called post_time but I can't make sense of what is in that collum - it is 11 numeric achacraters like 1228821530. Is this something that I can use?
     
    eddiemoth, Dec 8, 2008 IP
  6. mji2010

    mji2010 Active Member

    Messages:
    762
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #6
    that is the date in unix, you have to convert it with the date() function in php.
     
    mji2010, Dec 8, 2008 IP
  7. Sadie

    Sadie Active Member

    Messages:
    144
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #7
    If you have an associated table listing the date then it should be easy.
     
    Sadie, Dec 9, 2008 IP
  8. eddiemoth

    eddiemoth Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi mji2010, can you tell a little more about the conversion and include it as part of the mySQL query?
     
    eddiemoth, Dec 9, 2008 IP
  9. tenthletter

    tenthletter Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    SELECT *
    FROM cms_users
    WHERE user_posts >= '2000'

    sorry its difficult, you have to have date in the data base
     
    tenthletter, Dec 9, 2008 IP