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

Can I run a query to remove likes given by poster X

Discussion in 'XenForo Questions and Support' started by Lone Wolf, Mar 24, 2012.

  1. Lone Wolf

    Lone Wolf Well-Known Member

    I have had a few users sign up and then sign up additional accounts and use the other accounts to give themselves tons of likes
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. Lone Wolf

    Lone Wolf Well-Known Member

    Thanks Jake. Is there any way to delete likes between certain posters. Eg delete only the likes poster A gave to poster X but not to poster Y or poster Z
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    DELETE
    FROM xf_liked_content
    WHERE like_user_id = 2
    AND content_user_id = 3;
    
     
    otto and Lone Wolf like this.
  5. Lone Wolf

    Lone Wolf Well-Known Member

    Is there any way to find how many likes poster X gave to poster Y?

    Is it just the last query posted by jake with FIND instead of DELETE?
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    Change "DELETE" to "SELECT *"
     
    Lone Wolf likes this.
  7. Lone Wolf

    Lone Wolf Well-Known Member

    Thanks Kovifor
     
  8. Lone Wolf

    Lone Wolf Well-Known Member

    This doesn't work I get an error saying sql syntax error on line 2 or something like that.
     
  9. Jeremy

    Jeremy XenForo Moderator Staff Member

    What was the actual query you ran?
     
  10. Lone Wolf

    Lone Wolf Well-Known Member

    I changed delete to select like you said...

    Code:
    SELECT
    FROM xf_liked_content
    WHERE like_user_id = 2
    AND content_user_id = 3;
     
  11. Bob

    Bob Well-Known Member

    he said SELECT * <---- you left out the *

    Code:
    SELECT *
    FROM xf_liked_content
    WHERE like_user_id = 2
    AND content_user_id = 3;
     
    Lone Wolf and Jeremy like this.
  12. Lone Wolf

    Lone Wolf Well-Known Member

    Ok I tried that but now I'm getting this error...

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 30' at line 5
     
  13. Jeremy

    Jeremy XenForo Moderator Staff Member

    Are you running this via PhpMyAdmin? There is no limit clause in the above query, but try removing the semi-colon.
     
    otto and Lone Wolf like this.
  14. Lone Wolf

    Lone Wolf Well-Known Member

    Yes I am and removing the semi-colon worked, thanks. But it doesn't show me the posts which were liked. All I get is a content id. How do I convert this into the liked post. I want to see what was liked.
     
  15. Chris D

    Chris D XenForo Developer Staff Member

    The content ID is the post ID.

    This query is a little bit more complete:

    Code:
    SELECT liked.*, post.*, thread.*
    FROM xf_liked_content AS liked
    INNER JOIN xf_post AS post ON
        (liked.content_id = post.post_id)
    INNER JOIN xf_thread AS thread ON
        (post.thread_id = thread.thread_id)
    WHERE content_type = 'post'
        AND like_user_id = 2
        AND content_user_id = 3
    That will show you the entire details of the like, the entire details of the post that was liked and the entire details of the thread that post was in.
     
    otto, Lone Wolf and Jeremy like this.
  16. Lone Wolf

    Lone Wolf Well-Known Member

    Thanks Chris. The legends of your ninja xen skills are not exaggerated!

    Is there any way to search xf_post for a word or phrase and then display the post content via a query
     
  17. Chris D

    Chris D XenForo Developer Staff Member

    Code:
    SELECT post.post_id, post.thread_id, post.message, thread.title
    FROM xf_post AS post
    INNER JOIN xf_thread AS thread ON
        (thread.thread_id = post.thread_id)
    WHERE post.message LIKE '%resource%'
    :)

    Will display any post where the post content contains the word "resource". Will display the post_id, thread_id, message and the thread title.
     
    Lone Wolf likes this.
  18. Lone Wolf

    Lone Wolf Well-Known Member

    Thanks Chris. That's great
     

Share This Page