Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 updates to a derived table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-22 : 09:14:20
Nalin Raha writes "I feel like I've done this before but I can't seem to remember how it worked...

I want to update a derived table.

A simple update would look something like this:

update tUsers set username = 'my_name' where username = 'your_name'

I want to do something like this:

update (
select username, userlocation, usernum from tUsers tU
join tUsersLocations tL on tU.usernum = tL.UserNum
where tU.username like '%john%' and tL.LocationID = 1
) as derivedTable
set derivedTable.username = 'newname',
derivedTable.locationID = 2


This is assuming that there is one table that holds the name and one table that holds the location information ( a dumb idea but jsut for example) and a single update statement changes both of these columns.

Is this possible or am I losing it?
Thanks."
   

- Advertisement -