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

Sql query to get username and email from members

Discussion in 'General PHP and MySQL Discussions' started by Nuno, Aug 7, 2015.

  1. Nuno

    Nuno Active Member

    Hello

    I'm looking for help to get a SQL query to list the username and email of members who have posted threads and posts in two specific nodes.

    Any help on this?

    Thanks
     
  2. borbole

    borbole Well-Known Member

    Run this query in the SQL Box at phpmyadmin. (Choose the db where your forum resides on).

    Code:
    SELECT u.username, u.email, COUNT( * ) AS posts
    FROM xf_post AS p
    LEFT JOIN xf_thread AS t ON ( t.thread_id = p.thread_id ) 
    LEFT JOIN xf_user AS u ON ( u.user_id = p.user_id ) 
    WHERE t.node_id IN(x,y)
    GROUP BY p.user_id
    ORDER BY posts DESC 
    ;
    Replace x and y with the actual node id's that you want to pull the info. Also if you are using another prefix, other than the standard xf_, for your forum tables, then use that instead appended to the table names.
     
    Nuno likes this.

Share This Page