【发布时间】:2014-03-26 18:22:20
【问题描述】:
对于一个简单的数据结构如:
ID parentID Name (Table: VehicleType)
1 Vehicle
2 1 Small
3 2 Car
4 2 Motorcycle
5 1 Medium
6 5 Pickup
ID ItemType Name (Table: Vehicle)
1 3 Golf
2 4 125
是否可以使用 CTE 结果为:
VehicleType Name
Vehicle Golf
Small Golf
Car Golf
Vehicle 125
Small 125
Motorcycle 125
我想为每个找到的车辆类型创建寄存器,尝试了一切都没有成功。
【问题讨论】:
-
表
VehicleType对我来说似乎很不寻常。它提供什么信息?
标签: sql-server common-table-expression hierarchical-data