腾讯云数据仓库 TCHouse-P with 子查询及递归的使用

“`sqlcreate table t_area(id int,pid int,area varchar);insert into t_area values(1,null,’广东省’);insert into t_area values(2,1,’深圳市’);insert into t_area values(3,1,’东莞市’);insert into t_area values(4,2,’南山区’);inse。

相关产品
腾讯云数据仓库 TCHouse-P 产品页,含版本规格、价格与购买入口。

一、with 子查询

使用 with 子查询来选择 pid=1 的所有行:

with t_gd_city AS ( select * from t_area where pid=1)select * FROM t_gd_city;

查询结果:

id pid area
2 1 深圳市
3 1 东莞市
赞 (0)
上一篇 4天前
下一篇 4天前