WHERE
WHERE in the database is.....?
If a WHERE clause is included with SELECT and FROM we introduce a search condition. Only those rows (all) that satisfy the condition are returned in the result.
SELECT staff_no FROM staff WHERE name = 'Banner'; //name is data type string
Points:
- The WHERE clause uses a single predicate that evaluates to true or false.
- The referenced column is not returned but could be if so desired.
- Character strings are contained in single quotes.
- Uppercase and lowercase characters are not distinguished from one another. BANNER is the same as banner.
The logical processing follows the path specified below:
- FROM clause produces intermediate table, a copy of the staff table.
- WHERE clause produces a second intermediate table (via horizontal slicing and checking for true/false for each row against the predicate), with copies of all rows in the first intermediate table that satisfy the condition.
- SELECT takes the specified column from the second intermediate table to produce the final table.
- Aggregate functions are not allowed in the WHERE clause.
Move on to the operators.
Comments, suggestions, ideas to
Stuart Banner
