1、树形表,查询 所有的下边的记录
情景:根据当前记录的ID,要查询其所有子记录,每个子记录再查询当前子记录的所有子记录,如果有的话,一直迭代下去
当前表结构:
CREATE TABLE "PUBLIC"."XXX"( "ID" VARCHAR (32) NOT NULL , "NAME" VARCHAR (200), "PID" VARCHAR (32), "IF_DELETED" INTEGER, "CREATE_TIME" DATETIME) WITHOUT OIDS TABLESPACE "SYSTEM"; COMMENT ON TABLE "PUBLIC"."XXX" IS 'xx表';
解决方案:
SELECT * FROM XXX WHERE IF_DELETED = 0 START WITH ID = '2' CONNECT BY PID = PRIOR ID