我的代码似乎只显示在该字段中填写了一些信息的用户。如果缺少某个字段,则不会显示有关该用户的任何其他信息。
这是我目前的代码:
select m1.user_id as userid, m1.meta_value as firstname, m2.meta_value as lastname, m3.meta_value as email, m4.meta_value as phone, m5.meta_value as rolle, m6.meta_value as pw from wp_usermeta m1 join wp_usermeta m2 on (m2.user_id = m1.user_id and m2.meta_key = 'user_general_last_name') join wp_usermeta m3 on (m3.user_id = m1.user_id and m3.meta_key = 'user_general_email') join wp_usermeta m4 on (m4.user_id = m1.user_id and m4.meta_key = 'user_general_phone') join wp_usermeta m5 on (m5.user_id = m1.user_id and m5.meta_key = 'user_general_role') join wp_usermeta m6 on (m6.user_id = m1.user_id and m6.meta_key = 'user_general_pw') where m1.meta_key = 'user_general_first_name'
结果: Click here to see screenshot
但是,我还希望显示其他用户可能会遗漏某些字段。在使用sql和数据库时,我完全是新手,请具体说明。非常感谢您的帮助。