Database Reference
In-Depth Information
Figure 5.2
Songs Are Listed
Only if Matching
WHERE Clause
Conditions.
side of the comparison and a literal value on the right side. We can use liter-
als, expressions (such as adding two number columns), or another column
on either side of the condition.
Note:
For the sake of performance, it is always best to use functions not on
1
a side of the WHERE clause including a table or view column name.
Figure 5.3 shows a diagram of how the WHERE clause works to filter
out rows in the table. As you see in Figure 5.3, rows that meet the require-
ments are chosen, and those that fail the test are rejected.
The next example uses literals and expressions in the SELECT clause
plus columns not listed in the SELECT clause inside the WHERE clause
(columns not retrieved and displayed). In this query, the SELECT clause
contains two literals (in single quotes) and two columns. Once again the
column in the WHERE clause is not listed in the SELECT clause. Addi-
tionally, column headings are redundant and are disabled. Numerous other
things could be done to make this query more easily readable. The result is
shown in Figure 5.4.
SET HEADING OFF;
SELECT 'Song Name: ', S.TITLE
, 'Play time (M:SS): ', S.PLAYING_TIME
FROM SONG S
WHERE S.RECORDING_DATE > '01-JUL-2001';
 
Search WWH ::




Custom Search