Databases Reference
In-Depth Information
named CustomerNum and CustomerName. Because the tables are union compatible, it is possible to take the
union of these two tables, which is the appropriate operation for this example, as shown in Figure 3-54.
101
First query
UNION operation
Second query
FIGURE 3-54 SQL query to perform a union
The query results appear in Figure 3-55.
Customers of rep
35 or customers
who have orders on
file or both
FIGURE 3-55 Query results
If an SQL implementation truly supports the union operation, it will remove any duplicate rows. For
instance, any customers that are represented by sales rep 35 and that currently have orders on file will not
appear twice. Some SQL implementations have a union operation but will not remove duplicate values.
UPDATING TABLES
There are more uses to SQL than simply retrieving data from a database and creating tables. SQL has several
other capabilities, including the ability to update a database, as demonstrated in the following examples.
NOTE
If you plan to work through the examples in this section using Access, you should use a copy of the original Premiere Products
database because the version of the database used in subsequent chapters does not include these changes. As an alternative,
if you are using a DBMS that supports the ROLLBACK command (such as Oracle or MySQL), which reverses changes to a data-
base, you can ensure that your changes are undone by typing the word ROLLBACK before exiting the DBMS. If you have any ques-
tions concerning which of these (or other) approaches is appropriate for you, check with your instructor.
 
 
Search WWH ::




Custom Search