Subquery refers to embedding an SQL Sever statement into another SQL Sever statement. The database engine uses subqueries as virtual tables to perform queries. A subquery can be used as a table in a join statement and can be used as a value in a select statement, a SQL Sever query clause, or a statement of an SQL Sever query clause, it is mixed with data operation statements.
The execution of subqueries depends on nested queries. The query tree starts from the innermost layer and runs outward at the first layer. High-level nested queries can access the results of low-level nested queries.
What are related subqueries?
Different from classic subqueries, related subqueries depend on external queries. External queries are related to subqueries, especially in the where Statement of subqueries. The subquery method is to execute an external Query when the reference of an external query is found in the subquery, and return the result to the subquery. Then, perform the subquery operation on the result set returned by the external query.
Execution performance of related subqueries
Because the subquery in the related subquery is executed in the result set returned by the external query, its efficiency will definitely decrease. The performance of subqueries depends entirely on queries and related data. However, if the related subquery statements are written efficiently, the execution performance is better than those using several join and temporary tables.Program.