Specifying Criteria with the WHERE Clause

Note

Recall from Day 3 that the WHERE clause simply causes your queries to be more selective by limiting the amount of rows returned in the output.

Using just SELECT and FROM, you are limited to returning every row in a table. For example, using these two key words on the CHECKS table, you get all seven rows:

SQL> SELECT *
  2  FROM CHECKS;

   CHECK# PAYEE                   AMOUNT REMARKS
--------- -------------------- --------- -------------------
        1 MA BELL                    150 HAVE SONS NEXT TIME
        2 READING R.R.            245.34 TRAIN TO CHICAGO
        3 MA BELL                 200.32 CELLULAR PHONE
        4 LOCAL UTILITIES             98 GAS
        5 JOES STALE $ DENT          150 GROCERIES
       16 CASH                        25 WILD NIGHT OUT
       17 JOANS GAS                 25.1 GAS

7 rows selected.

With WHERE in your vocabulary, you can be more selective. ...

Get Sams Teach Yourself SQL in 21 Days, Fourth 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.