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

Trong khi hai truy vấn trước đó là rất tương tự, trong truy vấn đầu tiên theo thứ tự ưu tiên tự nhiên cho các toán tử Boolean gây ra và được đánh giá trước OR. Các HAY bao gồm các nhà văn hòa trong kết quả. Các truy vấn thứ hai được sử dụng dấu ngoặc đơn để ra lệnh rõ ràng thứ tự của các toán tử Boolean. Các HAY thu Nhà văn hòa và các sản phẩm với một ProductCode của 1018, 1019, hoặc 1020. . | Part II Manipulating Data with Select Result ProductCode ProductName 1019 Grand Daddy 1020 Black Ghost While the two preceding queries are very similar in the first query the natural order of precedence for Boolean operators caused the AND to be evaluated before the OR. The OR included the Air Writers in the results. The second query used parentheses to explicitly dictate the order of the Boolean operators. The OR collected the Air Writers and products with a ProductCode of 1018 1019 or 1020. This list was then anded with products that included the letter g in their names. Only products 1019 and 1020 passed both of those tests. Best Practice When coding complex Boolean or mathematical expressions explicitly stating your intentions with parentheses and detailed comments reduces misunderstandings and errors based on false assumptions. Surprisingly using the WHERE clause in a SELECT statement does not require the use of a FROM clause or any data source reference at all. A SELECT statement without a FROM clause returns a single row that includes any expressions in the select s column list. A WHERE clause on a non-table SELECT statement serves as a restriction to the entire SELECT statement. If the WHERE condition is true the SELECT statement will function as expected SELECT abc AS col WHERE 1 0 Result col abc 1 row s affected If the WHERE condition is false the SELECT statement is still executed but it returns zero rows SELECT abc AS col WHERE 1 0 Result col 0 row s affected 182 Introducing Basic Query Flow 8 Columns Stars Aliases and Expressions The title of this section may read like a bad tabloid headline but in all seriousness it refers to the fact that the SQL SELECT statement will return columns in the order in which they re listed in the SELECT statement. The column may be any expression or any column in the FROM clause. Following the FROM clause and the WHERE clause the next logical step in the query is the list of returned .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.