1. 程式人生 > >postgresql的分頁顯示-擷取字串-遞迴查詢

postgresql的分頁顯示-擷取字串-遞迴查詢

=======================================
>>>>>>>>>>>>>>postgresql<<<<<<<<<<<<<<<
=======================================
1.pgsql 分頁查詢
---------------------------------
select * from table_name limit A offset B
注:A為所需展示的行數
B為查詢的起始位置
---------------------------------------
select * from table_name where id >B limit A
========================================
2.pgsql 擷取字串函式
----------------------------------
給定子字串在字串中的位置 position ('源字串','子字串')
擷取字串 substring('源字串' from 起始位置 for 擷取字串長度);
substring('源字串',A,B);
注:A:起始位置 B.擷取長度
==========================================
3.pgsql 遞迴查詢
------------------------------------
從根節點往子節點查詢:
with recurse result as(
select id,pid,name from js_city where id=1
union all
select a.id,a.pid,a.name from js_city a join result b on b.id= a.pid)
select id,pid,name from result;