Monday, March 19, 2012

Get value from query to update another another table

I have a query that simply slelcts the min value of a specified field
from one table, I want to take that value to update a field in
annother table, just can not figure it out.(rzito@.si.rr.com) writes:

Quote:

Originally Posted by

I have a query that simply slelcts the min value of a specified field
from one table, I want to take that value to update a field in
annother table, just can not figure it out.


UPDATE tbl
SET col = (SELECT MIN(somecol) FROM othertbl)
WHERE ...

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

No comments:

Post a Comment