使用標量函式建立無限的查詢子部門

2021-06-08 01:20:19 字數 578 閱讀 8394

使用標量函式建立無限的查詢子部門(不包含自身)

alter

function   f_getchildren(@pid   int)

returns   @tree   table

(tdtid   int)

as begin

insert   @tree 

select   tdtid   from   tdept   where   tdtpid   =   @pid   --

父節點id 

while

@@rowcount

>   0   

insert   @tree 

select   a.tdtid   from   tdept   a   inner

join   @tree   b 

on   a.tdtpid   =   b.tdtid   and   a.tdtid   notin(

select   tdtid   from   @tree)

return

endselect

*from dbo.f_getchildren(7)

在MySQL中使用子查詢和標量子查詢的基本用法

一 mysql 子查詢 子查詢是將乙個 select 語句的查詢結果作為中間結果,供另乙個 sql 語句呼叫。mysql 支援 sql 標準要求的所有子查詢格式和操作,也擴充套件了特有的幾種特性。子查詢沒有固定的語法,乙個子查詢的例子如下 select from article where uid ...

EF中使用資料庫的標量值函式

參考資料 1 首先修改edmx裡新增的這個,將iscomposable屬性改為false,去掉returntype屬性,然後新增子節點 todistance aggregate false builtin false niladicfunction false iscomposable false ...

使用numpy的routines函式建立

numpy.ones shape,dtype none,order c 引數 shape int或int型別序列,表示矩陣形狀,dtype 輸出的資料型別,order c 或者 f 表示陣列在記憶體的存放次序是以行 c 為主還是以列 f 為主 返回值 給定要求下的單位矩陣 numpy.ones li...