简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM