The Language of SQL- P18

The Language of SQL- P18:Research has shown that, being pressed for time, most readers tend to skip the introduction of any book they happen to read and then proceed immediately to the first real chapter. With that fact firmly in mind, we will only cover relatively unimportant material in the introduction, such as an explanation of what you will and will not learn by reading this book. | CHAPTER 8 Boolean Logic Keywords Introduced AND OR NOT BETWEEN IN IS NULL In the previous chapter we introduced the concept of selection criteria but only in its simplest form. We re now going to expand on that concept to greatly enhance our ability to specify the rows that are returned from a SELECT. This is where the pure logic of SQL comes into play. In this chapter we are going to introduce a number of operators that will allow you to create complex logical expressions. With these new capabilities if a user comes to you and says that she wants a list of all female customers who live in ZIP codes 60601 through 62999 but excluding anyone who s under the age of 30 or who doesn t have an email address that will be something you can provide. Complex Logical Conditions The WHERE clause introduced in the previous chapter utilized only simple selection criteria. You saw WHERE clauses such as WHERE QuantityPurchased 5 The condition expressed in this WHERE clause is quite simple It returns all rows where the QuantityPurchased column has a value of 5. In the real world the selection of data is often far from straightforward. Accordingly let s now turn our attention to ways of specifying some more complex logical conditions in your selection criteria. 71 72 Chapter 8 Boolean Logic The ability to devise complex logical conditions is sometimes called Boolean logic. This term taken from mathematics refers to the ability to formulate complex conditions that are evaluated as either true or false. In the aforementioned example the condition QuantityPurchased 5 is evaluated as either true or false for each row in the table. Obviously you only want to see rows where the condition is evaluated as true. The principle keywords used to create complex Boolean logic are AND OR and NOT. These three operators are used to add additional functionality to the WHERE clause. In the proper combination the AND OR and NOT operators along with parentheses can specify just about any logical .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
3    81    2    02-07-2024
Đã 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.