TAILIEUCHUNG - SQL PROGRAMMING STYLE- P21

SQL PROGRAMMING STYLE- P21: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). | Pick Compact Constructions over Longer Equivalents 117 which is a little cleaner than WHERE a IN x y OR z IS NULL Use CASE Expressions Not Complex Nested Predicates An advanced trick in the WHERE clause is to use a CASE expression for a complex predicate with material implications. If you forgot your freshman logic a material implication logical operator is written as an arrow with two tails and it means p implies q or if p is true then q is true in English. WHERE CASE WHEN search condition 1 THEN 1 WHEN search condition 2 THEN 1 ELSE 0 END 1 The use of a function that returns one or zero when given a predicate as its parameter is called a characteristic function in logic and set theory. Review the rules for the CASE expression in section first so you understand it. The order of execution of the WHEN clauses can be used to optimize performance and avoid redundant tests. You can also nest CASE expressions inside the WHEN and THEN clauses of a containing CASE expression and display the logic as an indented tree structure. WHERE CASE WHEN search condition 1 THEN CASE WHEN search condition THEN 1 WHEN search condition THEN 1 ELSE 0 END WHEN search condition 2 THEN 1 . ELSE 0 END 1 The goal of this technique is to replace pages of long lists of simple theta expressions inside horrible levels of parentheses and to provide 118 CHAPTER 6 CODING CHOICES some short-circuit evaluation as a bonus. When the nesting is too messy to understand stop and reconsider your logic. Decision table tools such as Logic Gem are an excellent way to do this. Use Comments Rationale The best documentation for maintaining a program has been comments in the code. Perhaps it is easier for procedural language programmers to add comments because they are explaining in a narrative fashion what their program is doing. Unfortunately procedural language comments are often redundant if you can read the code. How much help did you get from UPDATE Teams SET score score 1 .

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.