0

I want to create the following Update-Statement: UPDATE table1 SET STATUSID=4 WHERE...

And after the where I want to use a select statement:

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

This select statement define the entries, which I want to update. How can I do this?

Stefan
  • 1
  • 1
  • Possible duplicate of [UPDATE from SELECT using SQL Server](http://stackoverflow.com/questions/2334712/update-from-select-using-sql-server) – profesor79 Mar 08 '16 at 12:14

1 Answers1

1

Try this:

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"
Giorgos Betsos
  • 71,379
  • 9
  • 63
  • 98