“With tmp as”的版本间的差异
跳到导航
跳到搜索
Jihongchang(讨论 | 贡献) (建立内容为“1”的新页面) |
Jihongchang(讨论 | 贡献) |
||
第1行: | 第1行: | ||
− | + | <syntaxhighlight lang="sql"> | |
+ | with tmp as ( | ||
+ | select * | ||
+ | from user_profile | ||
+ | ) | ||
+ | |||
+ | select * | ||
+ | from tmp | ||
+ | </syntaxhighlight>在SQL中,with as 通常被称为公共表达式(Common Table Expression,简称CTE)。 | ||
+ | |||
+ | 它的主要作用是允许在一个查询中定义一个临时的结果集,这个临时结果集可以在后续的查询部分中被引用和使用,从而使复杂的查询更具可读性和可维护性。 | ||
+ | |||
+ | <syntaxhighlight lang="sql"> | ||
+ | select version() | ||
+ | </syntaxhighlight>5.7.35-log 不支持,新版本应该支持。 |
2024年7月9日 (二) 11:18的最新版本
with tmp as (
select *
from user_profile
)
select *
from tmp
在SQL中,with as 通常被称为公共表达式(Common Table Expression,简称CTE)。
它的主要作用是允许在一个查询中定义一个临时的结果集,这个临时结果集可以在后续的查询部分中被引用和使用,从而使复杂的查询更具可读性和可维护性。
select version()
5.7.35-log 不支持,新版本应该支持。