自關聯的表(例如pid,id)怎麼判斷id屬於哪一級

2021-10-16 11:01:52 字數 1529 閱讀 7377

1樓:春復秋來到冬

方法一:傳統方法select m.id,m.

name,m.class,m.xid,x.

phone,x.address from member m,xinxi x where m.id=x.

id; 方法二:自然連線select * from member natural join xinxi; 方法三:直接連線select x.

id,m.name,m.class,m.

xid,x.phone,x.addre...

2樓:匿名使用者

--自關聯

with tb as

(select '1' id, '0' pid from dual union all

select '2' id, '1' pid from dual union all

select '3' id, '2' pid from dual union all

select '4' id, '3' pid from dual

)select count(*)  -- 結果為4

from (

select * from tb

connect by prior pid=id start wity id='4'  -- 從4開始整理成樹形結構);

選單表中id與pid的關聯關係怎麼寫sql查出來

3樓:怡寶還挺好喝

就用普通的內連線查詢就行!

4樓:鈽饗甾戥黛

select * from menu t1 inner join menu t2 on t1.id=t2.pid

sql如何判斷欄位id 屬於pid 陣列裡面的值 sql語句怎麼寫

5樓:匿名使用者

select * from table where pid like '%,'+id+',%'

還是不太理解你的意思,是這樣麼?

select * from table where id in (select id from table where pid like '%,'+id+',%' and pid='0,1,2,3,4')

6樓:

不明白你的意思,是要結果多顯示一列(表示id是否在pid中)?

7樓:陽光上的橋

where find_in_set(id,pid)<>0

mysql查詢同一張表中pid =id的sql語句怎麼寫?

8樓:匿名使用者

使用別名

select count(*)

from `category` `a` left join `category` `b`

on a.`pid` = b.`id`

9樓:匿名使用者

沒有懂你意思,【極品飛鴿】部落格作答

thinkphp 關聯查詢 怎麼統計關聯表查出來的資料數量

select count m.school id as sid,s.school name,m.mat name from school as s left join mat as m on s.id m.school id閒的無聊,回答問題,手機手打,打錯 內 自己排容錯 thinkphp求助,如...

表並列的關聯詞有哪些並列關係的關聯詞有哪些?

又 又 例 你又要我洗東西快,又要我洗得乾淨。2.一 邊 一邊 例 弟弟一邊唱歌,一邊跳舞。3.有時 有時 例 有時候早上去鍛鍊,有時候又傍晚去鍛鍊。4.一會兒 一會兒 例 沙漠中天氣惡劣,一會兒颳風,一會兒下雪 5.既 又 例 既會拉小提琴,又會吹笛子。6 也 例 爸爸不抽菸,也很少喝酒。7.一方...

如何用EXCEL表把相關聯的資料相加

看來你是做財務的。首先,想問一下 在每張表裡,你有設好統一的會計編碼或科目嗎?如工資為6 2001,股東借款,2 1001,辦公費用為6 2002,若有 開多一個工作表做為彙總表,寫一個sumif 公式 若沒有 先補上這些動作,再開多一個工作表做為彙總表,然後寫一個sumif公式 假設 表1名稱 銀...