Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update value from subquery

Status
Not open for further replies.

ktucci

Programmer
Joined
Apr 23, 2001
Messages
146
Location
US
how could i update a field with a value from a subquery...or is their another method of doing this
any help will be greatly appreciated
thanks in advance

update orders
set commissionable = 'this needs to be a value of a field from the subquery below'
where dbo.orders.id in (select id from orders where earned = '1' and commissionable is null)
 
No problems:
update orders
set commissionable = (select xxx from yyy)
where dbo.orders.id in (select id from orders where earned = '1' and commissionable is null)
the basic condition is wat the subquery must return only one single value(it can be max, min, avg, top 1,...) John Fill
1c.bmp


ivfmd@mail.md
 
Is there any way to do this with multiple updates? For example, I have two tables and need to do a multiple-row update on one, updating it with values from one column in another table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top