WITH AS 子查询部分【mysql5.7及以下不支持,mysql8.0及sqlserver支持】
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
解析:这个多个查询部分语法的写法,原理和单个查询部分一致