2013-02-22 24 views
-3

我想編寫一個選擇存儲過程,並在where子句中,我想檢查我正在執行select查詢的curent表的父表的一個字段的值的值,我該如何實現這一目標? 任何幫助,將不勝感激如何獲取sql存儲過程中表的父表的屬性?

+0

您是否知道設計時父表的名稱? – RobJohnson 2013-02-22 13:53:52

+0

@RobJohnson考慮父母表作爲tblParent和智利表tblChid – Karamafrooz 2013-02-22 13:55:07

+0

@downvoter關心評論? – Karamafrooz 2013-02-22 13:55:42

回答

2

你會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 
+0

非常感謝我得到了什麼:) – Karamafrooz 2013-02-22 13:56:50

相關問題