选择SQL更新

时间:2016-03-08 10:49:28

标签: mysql

我想创建以下Update-Statement: UPDATE table1 SET STATUSID = 4 WHERE ...

在我想要使用select语句之后:

select f.formtype,f.formuser,f.formstatusid
from table2 v, table1 f
where v.statusid = "1"
and v.date like "2010-06-17 15:40%"
and f.formtype = "4"
and f.formid = v.formid

这个select语句定义了我想要更新的条目。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

试试这个:

UPDATE table1 AS f
  JOIN table2 AS v ON f.formid = v.formid
SET STATUSID = 4
WHERE v.statusid = "1" AND v.date LIKE "2010-06-17 15:40%" AND f.formtype = "4"