-3
我想編寫一個選擇存儲過程,並在where子句中,我想檢查我正在執行select查詢的curent表的父表的一個字段的值的值,我該如何實現這一目標? 任何幫助,將不勝感激如何獲取sql存儲過程中表的父表的屬性?
我想編寫一個選擇存儲過程,並在where子句中,我想檢查我正在執行select查詢的curent表的父表的一個字段的值的值,我該如何實現這一目標? 任何幫助,將不勝感激如何獲取sql存儲過程中表的父表的屬性?
你會nedd JOIN
這些表。在不知道表格定義的情況下,您的查詢應該如下所示:
SELECT C.* --- List the columns you want here
FROM ChildTable C
INNER JOIN ParentTable P
ON C.ParentID = P.ID --- something along this lines
WHERE P.SomeField = 1 --- put here your condition on the parent table
非常感謝我得到了什麼:) – Karamafrooz 2013-02-22 13:56:50
您是否知道設計時父表的名稱? – RobJohnson 2013-02-22 13:53:52
@RobJohnson考慮父母表作爲tblParent和智利表tblChid – Karamafrooz 2013-02-22 13:55:07
@downvoter關心評論? – Karamafrooz 2013-02-22 13:55:42