TAILIEUCHUNG - SQL VISUAL QUICKSTART GUIDE- P29

SQL VISUAL QUICKSTART GUIDE- P29:SQL (pronounced es-kyoo-el) is the standard programming language for creating, updating, and retrieving information that is stored in databases. With SQL, you can turn your ordinary questions (“Where do our customers live?”) into statements that your database system can understand (SELECT DISTINCT city, state FROM customers;) | Chapter 8 Tips You also can write a self-join as a subquery Listings and and Figure . For information about self-joins see Creating a Self-Join in Chapter 7. You always can express an inner join as a subquery but not vice versa. This asymmetry occurs because inner joins are commutative you can join tables A to B in either order and get the same answer. Subqueries lack this property. You always can express an outer join as a subquery too even though outer joins aren t commutative. Listing This statement uses a subquery to list the authors who live in the same state as author A04 Klee Hull . See Figure for the result. Listing SELECT au_id au_fname au_lname state FROM authors WHERE state IN SELECT state FROM authors WHERE au_id A04 Listing This statement is equivalent to Listing but uses an inner join instead of a subquery. See Figure for the result. Listing SELECT FROM authors a1 INNER JOIN authors a2 ON WHERE A04 Subqueries vs. Joins au_id au_fname au_lname state A03 Hallie Hull CA A04 Klee Hull CA A06 Kellsey CA Figure Result of Listings and . 260 Subqueries Listing List all books whose price equals the highest book price. See Figure for the result. Listing SELECT title_id price FROM titles WHERE price SELECT MAX price FROM titles title_id price T03 Figure Result of Listing . Listing List the authors who live in the same city in which a publisher is located and include the publisher in the result. See Figure for the result. Listing SELECT FROM authors a INNER JOIN publishers p ON au_id city pub_id A03 San Francisco P02 A04 San Francisco P02 A05 New York P01 Figure Result of Listing . Favor subqueries if you re comparing an aggregate value to other values Listing and Figure . Without a subquery you d need two SELECT statements to list all the books with the highest .

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.