TAILIEUCHUNG - SQL PROGRAMMING STYLE- P24

SQL PROGRAMMING STYLE- P24:Im mot trying to teach you to program in SQL in this book. You might want to read that again. If that is what you wanted, there are better books. This ought to be the second book you buy, not the first. I assume that you already write SQL at some level and want to get better at it. If you want to learn SQL programming tricks, get a copy of my other book, SQL for Smarties (3rd edition, 2005). | 102 CHAPTER 6 CODING CHOICES 1. We build the CROSS JOIN of the two tables. Scan each row in the result set. 2. If the predicate tests TRUE for that row then you keep it. You also remove all rows derived from it from the CROSS JOIN. 3. If the predicate tests FALSE or UNKNOWN for that row then keep the columns from the preserved table convert all the columns from the unpreserved table to NULLs and remove the duplicates. So let us execute this by hand Let @ passed the first predicate Let passed the second predicate Tablel CROSS JOIN Table2 a b a c - 1 w 1 r @ 1 w 2 s 1 w 3 t 2 x 1 r 2 x 2 s @ 2 x 3 t 3 y 1 r 3 y 2 s 3 y 3 t @ the TRUE set 4 z 1 r 4 z 2 s 4 z 3 t Tablel LEFT OUTER JOIN Table2 a b a c - 3 y 3 t only TRUE row 1 w NULL NULL Sets of duplicates 1 w NULL NULL 1 w NULL NULL Pick Standard Constructions over Proprietary Constructions 103 2 x NULL NULL 2 x NULL NULL 2 x NULL NULL 3 y NULL NULL derived from the TRUE set - Remove 3 y NULL NULL 4 z NULL NULL 4 z NULL NULL 4 z NULL NULL The final results Tablel LEFT OUTER JOIN Table2 a b a c - 1 w NULL NULL 2 x NULL NULL 3 y 3 t 4 z NULL NULL The basic rule is that every row in the preserved table is represented in the results in at least one result row. Extended Equality and Proprietary Syntax Before the standard was set vendors all had a slightly different syntax with slightly different semantics. Most of them involved an extended equality operator based on the original Sybase implementation. There are limitations and serious problems with the extended equality however. Consider the two Chris Date tables Suppliers SupParts supno supno partno qty S1 S1 P1 100 S2 S1 P2 250 S3 S2 P1 100 S2 P2 250 104 CHAPTER 6 CODING CHOICES And let s do a Sybase-style extended equality OUTER JOIN like this select FROM Supplier SupParts WHERE AND qty 200 If I do the OUTER join first I get Suppliers LOJ SupParts supno supno partno qty S1 S1 P1 100 S1 S1 P2 250 S2 S2 P1 100 S2 S2 P2 250 S3 NULL

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.