我有這些頁面的SQL Server數據庫:SQL Server:如何選擇第二高分辨率?
+------------+--------------+-------------------------------+ | pageid | parentid | title | +------------+--------------+-------------------------------+ | 1 | null | Home | +------------+--------------+-------------------------------+ | 2 | 1 | News | +------------+--------------+-------------------------------+ | 3 | 1 | User | +------------+--------------+-------------------------------+ | 4 | 3 | Edit profile | +------------+--------------+-------------------------------+ | 5 | 3 | Messages | +------------+--------------+-------------------------------+ | 6 | 5 | View all | +------------+--------------+-------------------------------+
如何選擇任何行的第二高(電平)的parentid?因此,對於pageid = 6(查看全部),它應該返回parentid-> 3(用戶)。
這個問題有一個令人誤解的標題。也許它應該是「尋找父母的父母」,或者其他什麼 – 2010-01-14 00:20:01