Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 404893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:21:00+00:00 2026-05-12T17:21:00+00:00

This works if I remove the final JOIN line, but I’m not sure why

  • 0

This works if I remove the final JOIN line, but I’m not sure why it won’t work with it.
The last two JOIN statements are attempting to grab data (‘meta_value’) from different rows in the same table, the names of which can only be found by reading another corresponding column (‘meta_key’) in the same table. All this while joining everything on the user_id common in all 3 tables.

SELECT mod_membership.uid,
       mod_membership.wp_user_id,
       mod_membership.status,
       mod_membership.last_login,
       mod_membership.membership_type,
       mod_membership.membership_expiration,
       wp_users.user_login,
       wpm_a.meta_value AS first_name
  FROM mod_membership
  JOIN wp_users ON wp_users.ID = mod_membership.wp_user_id
  JOIN wp_usermeta AS wpm_a ON wpm_a.user_id = mod_membership.wp_user_id WHERE wpm_a.meta_key = 'first_name'
  JOIN wp_usermeta AS wpm_b ON wpm_b.user_id = mod_membership.wp_user_id WHERE wpm_b.meta_key = 'last_name'

How can I get this third JOIN to work, or use another method to get these results in a single result set, grouped on user_id?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:21:00+00:00Added an answer on May 12, 2026 at 5:21 pm

    try this:

     SELECT m.uid, m.wp_user_id,m.status,
         m.last_login,m.membership_type,
         m.membership_expiration,
         u.user_login,
         f.meta_value first_name,
         l.meta_value last_name
    From mod_membership m
       Join wp_users u 
          On u.ID = m.wp_user_id
       Left Join wp_usermeta f
          On f.user_id = m.wp_user_id
             And f.meta_key = 'first_name'
       Left Join wp_usermeta l
          On l.user_id = m.wp_user_id
             And l.meta_key = 'last_name'
    

    To answer your question the reason your syntax was not working is, first of all, there can be only one where clause per sql statement. You can’t add a where clause for each join, that’s what the “On” cluase is for…

    Secondly, the conditions in that Where clause are not applied until the final resultset has been generated, whereas join conditions are evaluated “along the way” as each intermediate result set is constructed from each successive join statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works Lastrow = 8, but not 9 (Type mismatch) If i remove If
this works .. $(select[title='First Choice'] option[text='hello']).remove(); A number of variations of this does not
When I remove the DOCTYPE line this code works the way I want it
I'm not sure how to describe this, but I'll try with some basic code:
I made this .htaccess file to try to remove final slash on links, but
I created this example The remove function doesn't work, and I can't figure out
This has to be obtained from a remote machine. The following query works not
This works but for some reason the comma is missing. data gets inserted as
Not too sure how I should properly describe the issue, but what I'm facing
My need is to strip embedded line breaks but not paragraph breaks when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.