時間:2024-03-12 20:33作者:下載吧人氣:19
一、with as 公用表表達式
類似VIEW,但是不并沒有創建對象,WITH AS 公用表表達式不創建對象,只能被后隨的SELECT語句,其作用:
1. 實現遞歸查詢(樹形結構)
2. 可以在一個語句中多次引用公用表表達式,使其更加簡潔
二、非遞歸的公共表達式
可以是定義列或自動列和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
網友評論