数据库表结构
读取数据库后在页面显示树状结构SQL语句为:select id, language,treeId
from test
start WITH id=1
connect BY prior id = treeId页面显示结果为:为什么显示的效果是全部分层,不是我想要的2层结构?想达到如下效果:+语言
-java
-c++
-c#求是否是SQL语句问题,请告诉我该怎样实现效果
读取数据库后在页面显示树状结构SQL语句为:select id, language,treeId
from test
start WITH id=1
connect BY prior id = treeId页面显示结果为:为什么显示的效果是全部分层,不是我想要的2层结构?想达到如下效果:+语言
-java
-c++
-c#求是否是SQL语句问题,请告诉我该怎样实现效果
with t as (
select 1 id, 'java' NAME ,'0' pid from dual union all
select 2 id, 'C#' NAME ,'1' pid from dual union all
select 3 id, 'Flex' NAME ,'1' pid from dual union all
select 4 id, '.net' NAME ,'3' pid from dual union all
select 5 id, 'javascript' NAME ,'3' pid from dual union all
select 6 id, 'vb' NAME ,'3' pid from dual union all
select 7 id, 'pb' NAME ,'3' pid from dual )
select lpad('|-',(level-1)*4,'|-')||lpad('『',2)|| name ||rpad('』',2) as tree
from t
start with t.pid = 0
connect by prior t.id = t.pid;这个么?
ID NUMBER(10) not null,
LANGUAGE VARCHAR2(30) not null,
TREEID NUMBER(10)
alter table TEST
add constraint PK_TEST_ID primary key (ID)
alter table TEST
add constraint FK_TEST_TREEID foreign key (TREEID)
references TEST (ID);现在效果(分四层):+语言
+java
+c++
-c#
想实现效果(分2层):+语言
-java
-c++
-c#
用的是ibatis框架,请指教!!!