SQL Query - user post nr. =0, help needed.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ceho
    Senior Member
    • Mar 2008
    • 439
    • 4.1.x

    [Forum] SQL Query - user post nr. =0, help needed.

    Hi there,

    I don't have much of a clue of SQL queries, so I'd like to ask for help.

    I need two queries, one for all members whose post number =0, and one for all members who have not posted since 30 days.

    I tried something like this:

    SELECT * FROM `vb_user` WHERE 'posts' =0
    but that doesn't seem to be correct.

    Could anyone help me please, also on the second needed query? Thank you very much!
    sigpic
  • borbole
    Senior Member
    • Feb 2010
    • 3074
    • 4.0.0

    #2
    Originally posted by ceho
    Hi there,

    I don't have much of a clue of SQL queries, so I'd like to ask for help.

    I need two queries, one for all members whose post number =0, and one for all members who have not posted since 30 days.

    I tried something like this:

    but that doesn't seem to be correct.

    Could anyone help me please, also on the second needed query? Thank you very much!
    Your query will not work because you have enclosed the posts field name inside quotes and that should not be the case.

    To get all members with 0 posts, run this query:

    Code:
    SELECT * FROM `vb_user` WHERE posts = 0;


    To get all members who have not posted since 30 days, run this query:

    Code:
    SELECT * FROM `user` WHERE lastpost < UNIX_TIMESTAMP( DATE_SUB( NOW(), INTERVAL 1 MONTH));

    I pressumed that your db tables have a vb_ prefix, based on the example you posted at your first post. If you are using another prefix then change it at the queries I posted above.

    Comment

    • ceho
      Senior Member
      • Mar 2008
      • 439
      • 4.1.x

      #3
      Oh great, thank you very much mate! Really appreciated!
      sigpic

      Comment

      • borbole
        Senior Member
        • Feb 2010
        • 3074
        • 4.0.0

        #4
        Originally posted by ceho
        Oh great, thank you very much mate! Really appreciated!
        Glad to have been of help.

        Comment

        • ceho
          Senior Member
          • Mar 2008
          • 439
          • 4.1.x

          #5
          Originally posted by borbole
          To get all members who have not posted since 30 days, run this query:

          Code:
          SELECT * FROM `user` WHERE lastpost < UNIX_TIMESTAMP( DATE_SUB( NOW(), INTERVAL 1 MONTH));
          Sorry to come back to this only now. This query includes all members with zero posts. To get all members who already posted before but only didn't post since 30 years I would probably need something like

          Code:
          SELECT * FROM `user` WHERE lastpost < UNIX_TIMESTAMP( DATE_SUB( NOW(), INTERVAL 1 MONTH)) AND WHERE posts > 1;
          I know this is not correct, as said I don't know how to write queries. Could someone please help me by telling me how to put this correctly? Or a better way how to get all users who did post in the past but didn't post since 30 days? Thankyou very much!
          sigpic

          Comment

          • Andy
            Senior Member
            • Jan 2002
            • 5886
            • 4.1.x

            #6
            Here is the correct query.

            Code:
            SELECT * FROM `user` WHERE lastpost < UNIX_TIMESTAMP( DATE_SUB( NOW(), INTERVAL 1 MONTH)) AND posts > 1

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...