tailieunhanh - Hướng dẫn học Microsoft SQL Server 2008 part 31

Truy vấn con là nền tảng cho SQL và có được một sự phát triển ổn định khả năng của mình. Một số cải tiến gần đây bao gồm: ■ SQL Server 2005 chứng kiến sự ra đời của cấu trúc áp dụng cho các chức năng người dùng định nghĩa và các truy vấn con. | Part II Manipulating Data With Select What s New with Subqueries Subqueries are fundamental to SQL and there s been a steady evolution of their capabilities. Significant recent improvements include the following SQL Server 2005 saw the introduction of the Apply structure for user-defined functions and subqueries. With SQL Server 2008 Microsoft adds row constructors that can be used in the subquery to provide hard-coded values to the query. Also new with SQL server 2008 is composable SQL a new way to plug together multiple DML statements. Anytime there s a new way to connect together different parts of the SQL query it opens new doors for experimentation and building new queries. It s good to see Microsoft continue to evolve and progress in critical areas such as subqueries. Simple Subqueries Simple subqueries are executed in the following order 1. The simple subquery is executed once. 2. The results are passed to the outer query. 3. The outer query is executed once. The most basic simple subquery returns a single scalar value which is then used as an expression in the outer query as follows SELECT SELECT 3 AS SubqueryValue Result SubqueryValue 3 The subquery SELECT 3 returns a single value of 3 which is passed to the outer SELECT statement. The outer SELECT statement is then executed as if it were the following SELECT 3 AS SubqueryValue Of course a subquery with only hard-coded values is of little use. A useful subquery fetches data from a table for example USE OBXKites SELECT ProductName 262 Including Data with Subqueries and CTEs 11 FROM WHERE ProductCategorylD Select ProductCategorylD FROM Where ProductCategoryName Kite To execute this query SQL Server first evaluates the subquery and returns a value to the outer query your unique identifier will be different from the one in this query Select ProductCategorylD FROM Where ProductCategoryName Kite Result ProductCategorylD .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.