sql server 2008 - extracting row values from a single table with a condition -


i have table contains 3 columns

id   name    rid 1    xx      4 2    yy      3 3    zz      2 4    aa      1 

now want result

id   name  rname 1    xx    aa 

based on rid refer id column , brings value of name column rname. please me query.

this return desired result:

select t1.id, t1.name, t2.name rname table t1 join table t2 on t1.rid = t2.id t1.id = 1 

Comments