[英]mysql inner join on two tables
Columns in table wp_users
: 表
wp_users
列:
id
user_login
Columns in table wp_usermeta
: 表
wp_usermeta
列:
user_id
meta_key [if equals 'primaryblog']
metav_value
The id in wp_users
and the user-id in wp_usermeta
are same. 在ID
wp_users
和用户ID wp_usermeta
相同。 I am expecting the result as 我期望结果为
id, user_login, meta_key, meta_value
I tried: 我试过了:
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
How to get the intended result? 如何获得预期的结果?
The JOIN comes before the WHERE clause: 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';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.