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 [ Fr, 26 Oktober 2007 22:04 ] [ ID #1855225 ]

Re: Get value from query to update another another table

(rzito [at] si.rr.com) writes:
> 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 [at] sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx
Erland Sommarskog [ Fr, 26 Oktober 2007 23:35 ] [ ID #1855230 ]
Datenbanken » comp.databases.ms-sqlserver » Get value from query to update another another table

Vorheriges Thema: ODBC Failed [Microsoft][ODBC SQL ...NamedPipes]ConnectionWrite (WrapperWrite()).
Nächstes Thema: Uploading image type using TSQL