WITH AS 子查詢部分【mysql5.7及以下不支持,mysql8.0及sqlserver支持】
子查詢部分的好處是部分查詢,不如有三個表連接在一條語句種出現多次
單個子查詢部分
with a as (select * from Student a inner join Course b ON a.Id=b.StudentId )select * from a
解析:這樣在此語句種每次查詢a都是查詢了student和course表的聯查集合
多個查詢部分語法
with a as (select * from Student), b as (select * from Course) select * from a inner join b on a.Id=b.StudentId
解析:這個多個查詢部分語法的寫法,原理和單個查詢部分一致
