一、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 | 东莞市 |
“`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。
使用 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 | 东莞市 |