SQLTeam.com | Weblogs | Forums

Select column and display another column from same table

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
Rose John
Nancy John
April Nancy

all at the same table.
please help.

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