[英]insert using sub-query and inner join
i have these two tables. 我有这两张桌子。
The first is the users_details table 第一个是users_details表
Second is the users_posts table. 第二个是users_posts表。
i want to fill the column postedby_name with username from the first column. 我想在第一列中用用户名填充postdby_name列。
I tried a combination of inner join and sub-query but could not do it. 我尝试了内部联接和子查询的组合,但无法做到。
This is the code that i have now. 这是我现在拥有的代码。
update users_posts
set users_posts.postedby_name =
(select username from users_details inner join users_posts where
users_posts.postedby = users_details.id);
How to Accomplish this.? 如何做到这一点?
Update users_posts inner join users_details
on users_posts.postedby = users_details.id
set users_posts.postedby_name=users_details.username
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.