Stefan
Stefan

Reputation: 1

SQL Update with Select

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?

Upvotes: 0

Views: 59

Answers (1)

Giorgos Betsos
Giorgos Betsos

Reputation: 72225

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"

Upvotes: 1

Related Questions