Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

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

  • #2
    Originally posted by ceho View Post
    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


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

      Comment


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

        Comment


        • #5
          Originally posted by borbole View Post
          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


          • #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...
            X