Database Reference
In-Depth Information
Observe an important difference between IN and NOT IN. A row qualifies for an IN condi-
tion if the column is equal to any of the values in the parentheses. However, a row qualifies for
a NOT IN condition if it is not equal to all of the items in the parentheses.
Ranges in SQL WheRe Clauses
SQL WHERE clauses can specify ranges of data values by using the SQL BETWEEN keyword .
For example, the following SQL statement:
/* *** SQL-Query-CH02-19 *** */
SELECT *
FROM
ORDER_ITEM
WHERE
ExtendedPrice BETWEEN 100 AND 200;
will produce the following results:
Notice that both the ends of the range, 100 and 200, are included in the resulting table. The
preceding SQL statement is equivalent to the SQL query:
/* *** SQL-Query-CH02-20 *** */
SELECT *
FROM
ORDER_ITEM
WHERE
ExtendedPrice >= 100
AND
ExtendedPrice <= 200;
And which, of course, produces identical results:
Wildcards in SQL WheRe Clauses
The SQL LIKE keyword can be used in SQL WHERE clauses to specify matches on portions of
column values. For example, suppose we want to find the rows in the SKU_DATA table for all
buyers whose first name is Pete. To find such rows, we use the SQL keyword LIKE with the SQL
percent sign (%) wildcard character , as shown in the SQL query:
/* *** SQL-Query-CH02-21 *** */
SELECT *
FROM
SKU_DATA
WHERE
Buyer LIKE 'Pete%';
 
 
Search WWH ::




Custom Search