1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with mySQL query

Discussion in 'General XenForo Discussion and Feedback' started by cmeinck, Jul 21, 2013.

  1. cmeinck

    cmeinck Well-Known Member

    I need help finding threads that have zero replies and a character count below a certain number. So for example, I would like a mySQL query that delivers threads with 0 replies and less than 50 characters. On a side note, this would make a great plugin.

    Thanks in advance.
     
  2. Arty

    Arty Well-Known Member

    edit: oops. misread
     
  3. cmeinck

    cmeinck Well-Known Member

    Thank you, I appreciate the help. (y)
     
  4. Arty

    Arty Well-Known Member

    Fixed. Somehow managed to misread your first post. Here is correct query:
    Code:
    SELECT t.thread_id FROM `xf_thread` t LEFT JOIN xf_post p ON (t.first_post_id = p.post_id) WHERE t.reply_count = 0 AND LENGTH(p.message) < 50
     
  5. AndyB

    AndyB Well-Known Member

    This will give you the post_id

    Code:
    SELECT xf_post.post_id
    FROM xf_thread
    INNER JOIN xf_post ON xf_post.post_id = xf_thread.first_post_id
    WHERE xf_thread.reply_count=0
    AND LENGTH(xf_post.message) > 50
    
    This will give you the thread_id

    Code:
    SELECT xf_thread.thread_id
    FROM xf_thread
    INNER JOIN xf_post ON xf_post.post_id = xf_thread.first_post_id
    WHERE xf_thread.reply_count=0
    AND LENGTH(xf_post.message) > 50
    
     
    Marcus likes this.
  6. Marcus

    Marcus Well-Known Member

    As a note, BBCodes are also counted as characters.
     
  7. cmeinck

    cmeinck Well-Known Member

    When I run these queries and click edit, I get an errors.

    Any suggestions on how I can run these queries and use them to check the thin content on my forum? What's the best way to find and export content in a format that would allow me to perform searches within XenForo.
     
  8. AndyB

    AndyB Well-Known Member

    You need to indicate which errors you get.
     

Share This Page