The Language of SQL- P29

The Language of SQL- P29: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. | 126 Chapter 12 Combining Tables with an Outer Join are listed in a left or right join is significant. However there is some flexibility in listing the tables in situations where there are three or more tables. The order of the left or right join keywords can be switched around if desired. Let s again look at the original FROM clause from the previous SELECT FROM Customers LEFT JOIN Orders ON LEFT JOIN Refunds ON We ve already seen that you can list the Refunds table first and the Customers table last as long as you convert everything to right joins as in FROM Refunds RIGHT JOIN Orders ON RIGHT JOIN Customers ON Is it possible to list the Customers table first and then the Refunds table followed by the Orders table Yes as long as you re willing to mix left and right joins together and throw in some parentheses. The following is equivalent to the above FROM Customers LEFT JOIN Refunds RIGHT JOIN Orders ON ON What was originally a fairly simple statement has now turned into something unnecessarily complex. Our advice is to stick with the LEFT JOIN keyword and avoid parentheses when devising complex FROM clauses with multiple tables. Full Joins The remaining outer join type is the full join. You ve seen that in left and right joins one table is primary and the other one is secondary. Alternatively you can say that one table is required and one is optional which means that when matching two tables rows in the secondary or optional table don t necessarily have to exist. Full Joins 127 In the inner join both tables are primary or required . When matching two tables there has to be a match between both tables for a row of data to be selected. In the full join both tables are secondary or optional . In this situation if we re matching rows in table A and table B then

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
Đã 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.