mysql - SQL - Update Junction Table Based on Values in User Table -


i have new migration creates many-to-many relationship between user , organization through junction table called organization_member. since trying migrate current values of organization_id , user_id on user table junction table represent relationship, thought try join , update, can't seem figure out how query both tables , take existing columns on user , update relationship doesn't exist. here original thought:

update `om` set `om`.`user_id` = `u`.`user_id`, `om`.`organization_id` = `u`.`organization_id` `user` `u` left join `organization_member` `om` on `u`.`user_id` = `om`.`user_id` `u`.`organization_id` not null; 

but error @

'from `user` `u` left join `organization_member` `om` on `u`.`user_id` = `o' @ line 3 

any great!

in mysql, join part of update. there no separate from:

update `user` `u` join        `organization_member` `om`        on `u`.`user_id` = `om`.`user_id`     set `om`.`user_id` = `u`.`user_id`,         `om`.`organization_id` = `u`.`organization_id`     `u`.`organization_id` not null; 

a left join inappropriate. want update om, need matching row update


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -