根据 MySQL 中的另一个表更新关系表
问题描述:
我有两个表 TABLE1 和 TABLE2.现在我想更新关系表 (TABLE2) 中的值,将主表 (TABLE1) 的 ID 与另一个表 ID 匹配,并从另一个表中获取值并更新到该关系表中.
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.
我该怎么做?
TABLE1
ID
NAME
TABLE2
AUTO_ID
ID
VALUE
LANGUAGE_ID
现在,我有与
TABLE1_OLD
ID
NAME
TABLE2_OLD
AUTO_ID
ID
VALUE
LANGUAGE_ID
所以我想做的是,想从旧表中获取 LANGUAGE_ID 2 值并根据 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;