Loading...

The SQL Workshop by Frank Solomon Prashanth Jayaram and Awni Al Saqqa

The SQL Workshop by Frank Solomon Prashanth Jayaram and Awni Al Saqqa

Author:Frank Solomon, Prashanth Jayaram, and Awni Al Saqqa
Language: eng
Format: epub
Publisher: Packt Publishing Pvt ltd
Published: 2019-12-27T00:00:00+00:00


Figure 7.2: A MySQL subquery

We'll focus on the inner query—the subquery—first, and then work it out from there. In this query, we started with the following SQL query, which shows all the ProductID values in the OrderItems table:

SELECT ProductID FROM OrderItems

We placed this query inside parentheses to make it a subquery. In the outer query, the SELECT and FROM clauses have the columns from the Products table that we require. The outer query WHERE clause uses NOT IN to filter out the Products table rows that don't exist in the subquery. The ORDER BY clause sorted the result set by ProductID.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.