根据 MySQL 中的另一个表更新关系表 [英] Update Relational table based on another table in MySQL

查看:51
本文介绍了根据 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;

这篇关于根据 MySQL 中的另一个表更新关系表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆