SQL使用with構(gòu)建臨時表
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
with x as ( select 1 as id ,'Adam' as name from dual union all select 2 as id ,'John' as name from dual ) select * from x 這樣就構(gòu)造了一個由兩行組成的臨時表。 如果需要構(gòu)造臨時表來表示表間關(guān)系: with a as (select 1 as id from dual union all select 2 as id from dual) , b as (select 1 as id,'Adam' as name from dual union all select 3 as id,'Tom' as name from dual) select a.id,b.name from a left join b on a.id=b.id 使用逗號來表示兩表并列,就可以構(gòu)造兩個臨時表了。 該文章在 2024/3/20 14:57:45 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |