Membership 2 Pro DB tables question and how to run SQL query


I'd like to know what is the purpose of the "ms_relationship" records in the wp_posts table. What are they for and what kind of data exactly is stored in them?

More importantly, how can I run a SQL query to grab all members of a specific membership?

  • Paul Kevin

    Hello James Wang ,

    Hope you are well today. The "ms_relationship" are custom post types that hold the subscription information of a user to a membership.
    Regarding the query, please check as follows. Make sure to change the "wp_" prefix to match your database prefix and the number 16 is the ID of the membership

    select u.ID, u.user_email, u.user_nicename, s.post_title as 'Membership' from wp_users u LEFT JOIN wp_posts m ON( substring_index(substring_index(m.post_content,',',1),':',-1) = u.ID ) LEFT JOIN wp_posts s ON(s.ID = substring_index(substring_index(m.post_content,',',-1),':',-1)) where  substring_index(substring_index(m.post_content,',',-1),':',-1) = 16;

    Warm Regards
    Paul Kevin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.