0

i have these two tables.
The first is the users_details table

Users_Details Table

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.?

1 Answer 1

4
Update users_posts inner join users_details  
on users_posts.postedby = users_details.id 
set users_posts.postedby_name=users_details.username
3
  • No problem. I'd upvote your answer, but don't remember enough about SQL to know if it's correct.
    – Steve P.
    Commented Aug 2, 2013 at 4:45
  • @SteveP. its ok i can understand.
    – Amit Singh
    Commented Aug 2, 2013 at 4:46
  • @Narendra it happen sometime its in your mind but it didnt come out.Your always welcome
    – Amit Singh
    Commented Aug 2, 2013 at 4:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.