-2
我有一個表是這樣的:查找孩子遞歸
CREATE #TableName TABLE (
Id int,
Id_Group int,
Id_Menu int
)
INSERT INTO #TableName VALUES
(1, 20005, 1014),(2, 20003, 1054),(3, 20005, 1058),
(4, 20004, 1055),(5, 20004, 1056),(6, 20004, 1057),
(7, 20003, 1053),(8, 1014, 0),(9, 20003, 1014),
(10, 20003, 1052),(11, 20003, 1164),(12, 20003, 1065),
(13, 20003, 1066),(14, 20003, 1067),(15, 20003, 1068),
(16, 20004, 1014),(17, 50100, 20003),(18, 50200, 20003),
(19, 50100, 20004),(20, 50200, 20004),(21, 50100, 20005),
(22, 50200, 20005)
我得到Id_Menu
例如1014
它必須找到它的id_menu
必須等於1014
,結果是記錄20003, 20004, 20005
和結果列表我必須找到它的所有記錄id_menu
s是20003, 20004, 20005
等
我該怎麼做?