Can we have multiple alias names for a single table?
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
,[columns]
)
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]
No, not on the same table, but you can select the same table twice and give each a different alias.
SELECT alias1.*, alias2.*
FROM mytable alias1, mytable alias2
This will then allow you to use the same table for a different purpose within a single query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With