Earlier, we mentioned there are two different approaches to SELECT and subquery statements.
- The first approach is the IN clause, which we have already covered.
- The second is the EQUALS clause, indicated quite simply with the = sign.
The syntax for the two clauses is nearly identical, with the = sign substituted for the IN phrase:
There is one requirement if you use this approach. Make sure the subquery statement returns only one value.
With the IN clause, you returned a list of values used as a comparison. With the EQUALS approach, there can be one and only one value represented when the results of the subquery are evaluated.
The subselect statement can have nearly any additional clauses that you can put on a standard SELECT statement.
You can use WHERE, or you can use the keywords that you are familiar with from your experience with SQL.
In the next lesson, the details about using the DISTINCT keyword and how you can integrate it into your SELECT
(and sub-SELECT) statements will be discussed.