|
Defining Selection Criteria Continued from The SELECT statement In the SELECT statements we've shown so far, we've limited the number of columns in the result table but returned all of the rows. Let's look at how to qualify the SELECT statement so it returns only the rows you want to see: SELECT columns FROM tables [WHERE predicates] ; The WHERE clause sets conditions that rows must meet in order to be included in the result table. These conditions are specified in one or more predicates. (A predicate states a possible truth about something.) If the predicate for any given row is true, that row is included in the result table; otherwise it is left out. In SQL statements, predicates are usually expressed through comparisons. For example, if you wanted to see all of the employees whose last name was Jones, you would use the following SELECT statement: SELECT * FROM EMPLOYEES WHERE LAST_NAME = 'Jones' ; The LAST_NAME = 'Jones' part is the predicate. When executing this statement, SQL compares the value of each row's LAST_NAME to 'Jones'. If an employee's last name is Jones, the predicate is true, and that employee's information will be included in the result table. (See Table 6.) Next: Comparisons and Logical Connectors Published as PC Tech Feature in the 11/17/98 issue of PC Magazine.
Elsewhere on ZDNet
|
|
TOP |
Copyright (c) 1998 Ziff-Davis Inc. |