Database Reference
In-Depth Information
Output
+----------------+------------+
| prod_name | prod_price |
+----------------+------------+
| .5 ton anvil | 5.99 |
| 1 ton anvil | 9.99 |
| Bird seed | 10.00 |
| Oil can | 8.99 |
| TNT (5 sticks) | 10.00 |
+----------------+------------+
Analysis
As seen in this example, when BETWEEN is used, two values must be
specified—the low end and high end of the desired range. The two values must
also be separated by the AND keyword. BETWEEN matches all the values in the
range, including the specified range start and end values.
Checking for No Value
When a table is created, the table designer can specify whether individual col-
umns can contain no value. When a column contains no value, it is said to
contain a NULL value.
New Term
NULL No value , as opposed to a field containing 0 , or an empty string, or just
spaces.
To determine if a value is NULL , you cannot simply check to see if = NULL .
Instead, the SELECT statement has a special WHERE clause that can be used to
check for columns with NULL values—the IS NULL clause. The syntax looks
like this:
Input
SELECT prod_name
FROM products
WHERE prod_price IS NULL;
This statement returns a list of all products that have no price (an empty
prod_price field, not a price of 0 ), and because there are none, no data is
returned. The customers table, however, does contain columns with NULL
values—the cust_email column contains NULL if a customer has no e-mail
address on file:
 
 
Search WWH ::




Custom Search