© Clare Churcher 2016

Clare Churcher, Beginning SQL Queries, 10.1007/978-1-4842-1955-3_4

4. Subqueries

Clare Churcher

(1)Studio B Productions, Great Neck, New York, USA

In the previous chapters, we looked at retrieving a subset of rows and columns from a single table, and we also looked at how Cartesian products and joins can be used to retrieve data from two or more tables. In many of the examples it was possible to construct quite different SQL queries to produce the same result. Depending on the context or the problem you will probably find that one approach will feel more natural.

As queries become more complicated, we might find that we can think of SQL expressions for small parts of a query but not for the whole lot in one go. It is possible ...

Get Beginning SQL Queries: From Novice to Professional, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.