sql >> Databasteknik >  >> RDS >> Sqlserver

SQL Rekursiv fråga returnerar endast den sista raden

with recury as (
Select 
fs1.ID ,fs1.FParent,fs1.FName 
from  FoldersStructure as  fs1
where fs1.ID=8

union all
select fs2.id,fs2.FParent,fs2.FName 
from FoldersStructure as  fs2
inner join recury as r on fs2.ID= r.FParent

)
select ID,FParent,FName
from recury 
order by ID 

SQL-Fiddle



  1. Hur definierar man en anpassad ordning i ORDER BY-satsen?

  2. 7645 Null eller tomt fulltextpredikat

  3. Rails3 kan inte spara 'ñ' till Oracle 11g

  4. Markera aktuellt sidnummer PHP-paginering