特别用法
apply
- apply有两种形式:
cross apply和outer apply - 语法:
<left_table_expression> {cross|outer} apply <right_table_expression> - apply运算方式
- 把右表表达式(
)应用到左表( )输入的行; - 添加外部行;
- 使用apply就像是先计算左输入,让后为左输入中的每一行计算一次右输入。
cross apply类似inner join,outer apply类似left join只是效率有所不同,需要根据具体的使用选择,如果join太慢的情况下可以选择优化的时候修改成apply方式试试。
- 把右表表达式(
The MSDN definition is:
"The APPLY operator is similar to the JOIN operator, but the difference is that the right-hand side operator of APPLY can reference columns from the left-hand side".
参考文档
首页 > 学习总览 > 开发语言 > SQL server