TAILIEUCHUNG - The Language of SQL- P35

The Language of SQL- P35: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. | 156 Chapter 15 Set Logic All corresponding columns in each SELECT columnlist must have the same or compatible datatypes. With reference to these rules notice that both SELECT statements in the search have three columns. Each of the three columns has data in the same order and with the same datatype. When using the UNION you should use column aliases to give the same column name to all corresponding columns. In our example the first column of the first SELECT has an original name of OrderDate. The first column of the second SELECT has an original name of ReturnDate. To ensure that the first column in the final result has the desired name both OrderDate and ReturnDate are given a column alias of Date. This also allows the column to be referenced in an ORDER BY columnlist. Also notice that the second column of each SELECT utilizes literal values. We created a calculated column named Type which has a value of either Order or Return. This allows us to tell which table each row comes from. Finally notice that the ORDER BY clause applies to the final results of both queries combined together. This is how it should be since there would be no point to applying a sort to the individual queries. At this point it is useful to step back and talk about why it was necessary to employ the UNION operator rather than simply join the Orders and Returns tables together in a single SELECT statement. Since both tables have a CustomerID column why didn t we simply join the two tables together on this column The problem with this possibility is that the two tables are really only indirectly related to each. Customers can place orders and customers can initiate returns but there is no direct connection between orders and returns. Additionally even if there were a direct connection between the two tables a join would not accomplish what is desired. With a proper join related information can be placed together on the same row. In this case however we are interested in showing orders and .

TỪ KHÓA LIÊN QUAN
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.