Reputation: 3
I have a select statement that returns a few fields from a table.
I want to update only the results of that select, giving a fixed value in one field.
I though of that, but it doesn't work:
UPDATE
(SELECT * from table.... where...)
SET field1=1
Upvotes: 0
Views: 1124
Reputation: 2604
If your are using t-sql
UPDATE SET field = fixed value from tablename where filed....
Upvotes: 0
Reputation: 79979
You didn't need a SELECT
, just use a WHERE
clause directly with the UPDATE
to do this only for the rows that statify the condition in the WHERE
clause:
UPDATE t
SET field1 = 1
FROM table AS t
WHERE ...
Upvotes: 2