表wp_users
中的列:
id
user_login
表wp_usermeta
中的列:
user_id
meta_key [if equals 'primaryblog']
metav_value
wp_users
中的ID和wp_usermeta
中的用户ID相同。我期待结果为
id, user_login, meta_key, meta_value
我试过了:
select a.user_id,a.meta_key,a.meta_value
from wp_usermeta as a
where meta_key = 'primaryblog'
inner join b.id, b.user_login
from wp_users as b on a.user_id=b.id
如何获得预期的结果?
答案 0 :(得分:1)
JOIN在WHERE子句之前:
SELECT
a.id, a.user_login, b.meta_key, b.meta_value
FROM wp_users a
JOIN wp_usermeta b ON a.id = b.user_id
WHERE meta_key = 'primaryblog';