tailieunhanh - Beginning Databases with Postgre SQL phần 3
hay hệ thống UNIX như Linux, FreeBSD, AIX, Solaris, HP-UX, hoặc Mac OS X-nó không phải là khó khăn để biên dịch PostgreSQL từ mã nguồn. Chúng tôi cũng sẽ làm thế nào để cài đặt và thiết lập PostgreSQL trên nền tảng Windows, sử dụng trình cài đặt Windows được giới thiệu trong phiên bản PostgreSQL 8,0. | CHAPTER 4 ACCESSING YOUR DATA 109 we need to use an extra table the item table to get at the item description. The rest of the query however is pretty much as before bpsimple SELECT bpsimple- bpsimple- FROM customer orderinfo orderline item bpsimple- WHERE bpsimple- AND bpsimple- AND bpsimple- AND bpsimple- Ann AND bpsimple- Stones fname lname date_placed description quantity ------- -------- ------------- -------------- ---------- Ann Stones 2004-06-23 Wood Puzzle 1 Ann Stones 2004-06-23 Tissues 2 Ann Stones 2004-06-23 Fan Large 2 Ann Stones 2004-06-23 Carrier Bag 1 Ann Stones 2004-07-21 Wood Puzzle 1 Ann Stones 2004-07-21 Linux CD 1 6 rows bpsimple How It Works Once you have seen how three-table joins work it s not difficult to extend the idea to more tables. We added the item description to the list of columns to be shown added the item table to the list of tables to select from and added the information about how to relate the item table to the tables we already had . You will notice that Wood Puzzle is listed twice since it was purchased on two different occasions. In this SELECT we have displayed at least one column from each of the tables we used in our join. There is actually no need to do this. If we had just wanted the customer name and item description we could have simply chosen not to retrieve the columns we didn t need. A version retrieving fewer columns is just as valid and may be marginally more efficient than our earlier attempt SELECT FROM customer orderinfo orderline item WHERE AND AND AND Ann AND .
đang nạp các trang xem trước