SQLTeam.com | Weblogs | Forums

Select column and display another column from same table


#1

i have table as below:

ID Name UserCreatedID
1 John
2 Rose 1
3 Nancy 1
4 April 3

so what i want to display at below:

Name UserCreatedbyName
John
Rose John
Nancy John
April Nancy

all at the same table.
please help.


#2
select a.name
      ,isnull(b.name,'') as usercreatedbyname
  from yourtable as a
       left outer join yourtable as b
                    on b.id=a.usercreatedid
;