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 2005 Forums
 Transact-SQL (2005)
 Update Column From Other DB Table...

Author  Topic 

alexjamesbrown
Starting Member

48 Posts

Posted - 2009-01-09 : 09:10:48
Hi,
Currently, we have a users table with a schema like:

UserID | UserName
1 | alexjamesbrown
2 | johnsmith
3 | jobloggs

We then have a table (we'll call this profile for the sake of this..) with a schema like:

User | HairColour | FavouriteFood
1 | Brown | Pizza
2 | Blonde | Pasta
3 | Brown | Pizza

What i need to do is replace the User column in the Profile table with the actual user name, stored in the users table

something like...


update rating set creator = (SELECT username from dbo.Users where ID = ???)


Thanks for your help

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-01-09 : 09:31:09
All you need is only for display

select u.username,p.HairColour,p.FavouriteFood from users as u inner join profiles as p
on u.userid=p.user


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -