Con*_*lls 11
是.您需要为自联接执行此操作,例如,如果您有一个存储层次结构的表:
create table Foo (
FooID int
,ParentFooID int
,[columns]
)
Run Code Online (Sandbox Code Playgroud)
您可以通过以下查询进行联接以获取满足特定条件的父项的子项:
Select b.*
from Foo a
join Foo b
on a.FooID = b.ParentFooID
and [some condition filtering a]
Run Code Online (Sandbox Code Playgroud)
不,不在同一个表上,但您可以选择同一个表两次,并为每个表指定不同的别名。
SELECT alias1.*, alias2.*
FROM mytable alias1, mytable alias2
Run Code Online (Sandbox Code Playgroud)
这样您就可以在单个查询中将同一个表用于不同的目的。