Deviprasad Das Deviprasad Das - 11 months ago 43
SQL Question

Multiple Alias names for a table

Can we have multiple alias names for a single table?

Answer Source

Yes. You need to do this for a self join, for example f you have a table storing a hierarchy:

create table Foo (
    FooID int
   ,ParentFooID int

You can do a join to get the children of parents that satisfy a particular condition with a query like:

Select b.*
  from Foo a
  join Foo b
    on a.FooID = b.ParentFooID
   and [some condition filtering a]