简体   繁体   中英

Update Relational table based on another table in MySQL

I have two table TABLE1 and TABLE2. Now I want to update value in relational table(TABLE2) with matching a ID of Master table(TABLE1) with another table ID and take value from that another table and update into that relational table.

How can i do this?

TABLE1

ID    
NAME

TABLE2

AUTO_ID 
ID
VALUE
LANGUAGE_ID

Now, I have same tables like

TABLE1_OLD

ID
NAME

TABLE2_OLD

AUTO_ID
ID
VALUE
LANGUAGE_ID

So I want to do is, want to take LANGUAGE_ID 2 value from old table and update into new one depend on ID matched.

UPDATE table2 set table2.language_id = your_value_here
WHERE table1.id = table2.id;

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