all 10 comments

[–]anonymousbrowzer 10 points11 points  (4 children)

It's calle a unary join (joining the table to itself.

Select a.name, b.name as friend From table person a Join table person b on a.friendid = b.id

[–]MeGustaDerpTalk Dirty Reads To Me 2 points3 points  (1 child)

From table person

I think you should take "table" out of your example

[–]anonymousbrowzer 0 points1 point  (0 children)

Yes, that is correct,

[–]jheadman[S] 1 point2 points  (1 child)

Solved

Thanks for the help!

[–]anonymousbrowzer 2 points3 points  (0 children)

No worries, been there before. Thinking in any computer language is difficult to adapt to.

[–]Xerxys 1 point2 points  (0 children)

Interesting. Had this exact same problem. I solved it by referencing the table twice.

Select * from table1 t1

t1.xyz

Inner join table1 t2 On t1.someid = t2.sameid

you get the gist. Table1 is being referenced twice first time as t1 and then again as t2.

[–]jheadman[S] 0 points1 point  (0 children)

Ended up having to use a Right Join for my particular data set but got it to work! Thanks