sql怎麼獲取樹那樣的資料

2025-06-17 03:25:22 字數 1633 閱讀 1043

sql 查詢樹形資料。

1樓:網友

你的問題是怎麼從 部門表中獲得全稱。

select id,deptname from(select id,connect_by_isleaf "isleaf",sys_connect_by_path(name, '/') "deptname"

from dept

start with parentid = 0connect by prior id = parentid;

xx where = 1

* start with 最高階部門 ,如果最高部門是一營就應該 start with parentid = 0如果最高部門為司令部 且parentid 是null就應該 start with parentid is null**/

2樓:網友

如果樹的層數固定就可以用語句查詢,但效率比較低。例如你說的三層:

select id, from t1 inner join(select id, as name from t1 inner join

select id,name from t1 where parentid = 0) v1 on = v2 on =

3樓:網友

oracle 有 start with ..connect by 的語法。

sqlserver沒有,必須自己寫儲存過程實現。

樹形資料庫怎麼獲取子類

4樓:網友

with a as(select id,cast(名字 as varchar(200)) 名字, 父親名字 from 表名 where 父親名字=0

union all

select ,cast(a.名字+'\'+b.名字 as varchar(200)),b.父親名字。

from a join 表名 b on 父親名字)select *

from a

order by 2

將上述語句中的兩個「表名」改為你自己的表名即可。

如何用sql語句實現樹形的資料庫表查詢

5樓:佳妤婷小

如果樹的層數固定就可以用語句查詢,但效率比較低。例如你說的三層:

select id, from t1 inner join(select id, as name from t1 inner join

select id,name from t1 where parentid = 0) v1 on = v2 on =

關於sql查詢樹結構資料的語句

6樓:i_所謂_感情

為啥不在表結構里加一列證明這是第幾級呢?

jquery easyui 樹 怎麼構造樹形資料 從資料庫裡生成樹的json資料

7樓:匿名使用者

2012-7-31 23:32:18森怒殘攜jquery easyui 樹 怎麼構造樹形資料 從資料庫裡生成樹的json資料。

8樓:網友

將巢狀的list序列化成json就行了。

Vue資料怎麼獲取使用外部的資料

用 vue resource 請求後臺資料 詳細請看連結 http www.gonghaibo.cn vue 怎麼拿到router.push傳遞的資料 vue 怎麼拿到router.push傳遞的資料 主要有以下幾個步驟 1 設定好路由配置 router.map 這裡有2個關鍵點 a 給該路由命名,...

sql中怎麼表示「不等於」(資料庫,sql)

你的問題看不懂,你可以的網去搜一下那裡什麼樣的問題都可以解決。表示 不等於 符號,呵呵,希望能有幫助,兩種方法 1.2.where a 100 where a 100 或者where not a 100 where a 100 where a 100 a 100 或a 100都可以 那就是where...

資料庫誤刪除資料怎麼恢復,SQL資料庫裡的表誤刪除要怎麼恢復

刪除了就是刪除了,基本上不太可能恢復的,我記得有一個功能,可以找回刪除的資料,但是我們絕大多數的手機都沒有開著這個功能 回答親 你好 您的問題我已經看到了 麻煩您等待三分鐘 我需要整理一下答案。1.刪除放入 站,沒有在 站中清除資料。這種情況是最簡單的,進入 站,找到刪除的資料,右擊選擇恢復。2.刪...