mySQL查询使用两个表

时间:2012-11-02 12:43:54

标签: mysql sql

我有一个表(config),其中包含字段'type'和另一个表(用户),其中包含字段'status'。

字段“status”的某些值为空。

如果另一个表中的字段'type'等于'3',我想将字段'status'更改为'applied'。

您能解释一下如何进行此查询吗?

1 个答案:

答案 0 :(得分:0)

试试这个

update table2
inner join table1 on table1.id=table2.id 
and  table1.type=3 
set status=applied

id是两个表中的公共字段