O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

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

Comparing a Subquery Value by Using a Comparison Operator

You can use a subquery as a filter in a WHERE clause or HAVING clause by using one of the comparison operators (=, <>, <, <=, >, or >=). The important characteristics of a subquery comparison test are:

  • The comparison operators work the same way as they do in other comparisons (refer to Table 4.2 in Chapter 4).

  • The subquery can be simple or correlated (see “Simple and Correlated Subqueries” earlier in this chapter).

  • The subquery’s SELECT-clause list can include only one expression or column name.

  • The compared values must have the same data type or must be implicitly convertible to the same type (see “Converting Data Types with CAST()” in Chapter 5).

  • String comparisons may be case-insensitive ...

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