Tsql2008 Query Performance Optimization Chapter---APPLY

Source: Internet
Author: User

The Apply operator involves one or two of the following two steps (depending on the type of APPLY): 1.A1 applies the right-table expression to the row of the left table. 2.A2: Add an external row. The apply operator applies the right-table expression to each row in the left input. The right table expression can reference a column in the left input, and for each row in the left table, the expression to the right input is evaluated once. This step matches each row on the left and the corresponding row from the right expression and merges the resulting result set to return the combined result. Cross apply and OUTER apply always contain step A1, and only out apply contains step A2. if the inner (right) table expression returns an empty set for an outer (left) row, cross APPLY does not return the outer (left) row. OUTER APPLY returns such rows, and null is used as a placeholder for the properties of the inner table expression. Example: The following query returns data from two tables in the category of cars:SELECT p.[d_id],P.[c_title],P.[e_title],P.[d_time],A.d_titleFrom [Dingtai]. [dbo]. [D_news_product] As PCross APPLY (SELECT c.d_id,D_title,C.d_timeFrom dbo. D_category as CWHERE c.d_id = P.class_one--order by c.d_id DESC         ) as a GO------------------------Returns the result---------------------                  * If you want to return data that does not contain classes for cars, use out APPLY: SELECT p.[d_id],P.[c_title],P.[e_title],P.[d_time],A.d_titleFrom [Dingtai]. [dbo]. [D_news_product] As P OUTER APPLY (SELECT c.d_id, D_title,C.d_timeFrom dbo. D_category as CWHERE c.d_id = P.class_one--order by c.d_id DESC                     ) as a GO-----------------------Results-----------------------------------------------------------------Knowledge of supplemental words------------------------------------------------------------
Apply English [?? Pla?] Beauty [?? Pla?]
VT. Application; Coating Apply, use; Apply (medicine);
vi. application, request, applicable; applicable, suitable for; devote oneself to;
Examples I am continuing toapply for jobs I'm still looking for a job. Copyright? 2017Cheng. All rights Reserved.

Tsql2008 Query Performance Optimization Chapter---APPLY

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.