为来自不同 table 的记录查找相应的 id 值
Find corresponding id values for records from different table
我有 2 个 table 条目为:
过渡table:
From_Status_Id To_Status_Id PU_Id
5 1 868
5 2 868
5 3 868
5 4 868
8 5 868
8 2 868
8 3 868
状态table:
ProdStatus_Id ProdStatus_Desc
1 NoId-Staged
2 NoId-Running
3 Staged
4 Running
5 Complete
8 Inprogress
我需要以下格式的结果,它基本上是给定状态 ID 的相应状态描述值。
输出:
from_status to_status
Complete NoId-Staged
Complete NoId-Running
Complete Staged
Complete Running
Inprogress Complete
Inprogress NoId-Running
Inprogress Staged
我们如何使用连接来获得这个结果集?
SELECT S.ProdStatus_Des AS FROM_STATUS,S2.ProdStatus_Des AS TO_STATUS
FROM Transition AS T
JOIN Status AS S ON T.From_Status_Id=S.ProdStatus_Id
JOIN Status AS S2 ON T.To_Status_Id=S2.ProdStatus_Id
我有 2 个 table 条目为:
过渡table:
From_Status_Id To_Status_Id PU_Id
5 1 868
5 2 868
5 3 868
5 4 868
8 5 868
8 2 868
8 3 868
状态table:
ProdStatus_Id ProdStatus_Desc
1 NoId-Staged
2 NoId-Running
3 Staged
4 Running
5 Complete
8 Inprogress
我需要以下格式的结果,它基本上是给定状态 ID 的相应状态描述值。
输出:
from_status to_status
Complete NoId-Staged
Complete NoId-Running
Complete Staged
Complete Running
Inprogress Complete
Inprogress NoId-Running
Inprogress Staged
我们如何使用连接来获得这个结果集?
SELECT S.ProdStatus_Des AS FROM_STATUS,S2.ProdStatus_Des AS TO_STATUS
FROM Transition AS T
JOIN Status AS S ON T.From_Status_Id=S.ProdStatus_Id
JOIN Status AS S2 ON T.To_Status_Id=S2.ProdStatus_Id