Database Reference
In-Depth Information
Figure 6.11
BETWEEN selects from a range.
Figure 6.12
NOT applied to the BETWEEN query.
As another example, we will look at what happens if you select a single row from a table.
We will use the cookie table again, so select a single row as follows:
SELECT *
FROM
cookies
WHERE
cookieid = 3
This will definitely select a single row as we are selecting from the primary key column,
so there will be no other rows with the ID of 3. Run the query and notice what is returned.
Now add a NOT to the condition as follows:
SELECT *
FROM
cookies
WHERE
NOT (cookieid = 3)
You need to add the parentheses to ensure that the NOT works with the whole condition.
With this change, what will the query now select? Figure 6.13 shows the results.
Notice how the NOT has radically changed the results of the query; instead of returning
a single row, it now returns everything in the table apart from the specified row.
Search WWH ::




Custom Search