O'Reilly logo

SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, Second Edition by Michael J. Hernandez, John L. Viescas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Subqueries as Column Expressions

In Chapter 5, Getting More Than Simple Columns, you learned a lot about using expressions to generate calculated columns to be output by your query. We didn’t tell you then that you can also use a special type of SELECT statement—a subquery—to fetch data from another table, even if the table isn’t in your FROM clause.

Syntax

Let’s go back to the basics and take a look at a simple form of a SELECT statement in Figure 11-1.

Figure 11-1. The syntax diagram for a simple SELECT statement

This looks simple, but it really isn’t! In fact, the value expression part can be quite complex. Figure ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required