時間:2024-03-12 20:33作者:下載吧人氣:19
一、with as 公用表表達(dá)式
類似VIEW,但是不并沒有創(chuàng)建對象,WITH AS 公用表表達(dá)式不創(chuàng)建對象,只能被后隨的SELECT語句,其作用:
1. 實(shí)現(xiàn)遞歸查詢(樹形結(jié)構(gòu))
2. 可以在一個語句中多次引用公用表表達(dá)式,使其更加簡潔
二、非遞歸的公共表達(dá)式
可以是定義列或自動列和select into 效果差不多
–指定列
with withTmp1 (code,cName)
as
(
select id,Name from ClassUnis
)
select * from withTmp1
–自動列
with withTmp2
as
(
select * from ClassUnis
where Author = ‘system’
)
select * from withTmp2
網(wǎng)友評論