Lecture

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Outline 1 Introduction 2 JOIN UNION 3 Subquery 4 File I/O 2 / 16
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Outcome This is the second part of SQL SELECT, focusing on select data from multiple tables. Use JOIN to retrieve data. Use subqueries getting the same result. 3 / 16
Image of page 2
Introduction Most times, our data are separated into different tables. Using one SELECT query on one table is not enough. Here we have 2 methods to extract data from multiple tables. JOIN: combining tables together. Subquery: select data from multiple tables in a human-reading query. 4 / 16
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
UNION UNION combines records in different SELECT statement vertically. It is like append the second table at the end of first table. Those 2 tables should have same number of columns and same column type. The number of rows in the output after union should be: T1 + T2 (with duplicate rows) or T1 + T2 - Duplicate rows (without duplicate). You can union 2 or more SELECT statements together at the same time. 5 / 16
Image of page 4
UNION Query 1 ( SELECT . . FROM . . ) 2 UNION 3 ( SELECT . . FROM . . ) 4 UNION 5 ( SELECT . . FROM . . ) ; Note: The output table from SELECT statements must have same column number and same data type on each column.
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern