天天看點

postgres 遞歸

WITH RECURSIVE 别名 AS (
	select field1, field2, ... from 表 where xxxxx=xxxx
	union all 
	select field1, field2, ... 
	from 表, 别名
	where 别名.父級id = 表.id
	and xxxx = xxxx
) select field1, field2, ... from 别名 where xxxx=xxxx group by xxxx order by xxxx limit xxx, xxx
           

繼續閱讀