Database Reference
In-Depth Information
The query results appear in Figure 3-50.
100
Fields from the
Customer table
Fields from
the Rep table
Records ordered by
CustomerNum
FIGURE 3-50
Query results
When there is potential ambiguity in listing field names, you must qualify the fields involved. It is per-
missible to qualify other fields as well, even if there is no possible confusion. Some people prefer to qualify all
fields, which is certainly not a bad approach. In this text, however, you will qualify fields only when it is nec-
essary to do so.
EXAMPLE 25
List the number and name of each customer whose credit limit is $10,000 together with the number, last
name, and first name of the sales rep who represents the customer. Order the records by customer number.
In Example 24, the condition in the WHERE clause serves only to relate a customer to a sales rep.
Although relating a customer to a sales rep is essential in this example as well, you also need to restrict the
output to only those customers whose credit limit is $10,000. You can accomplish this goal by using the AND
operator to create a compound condition, as shown in Figure 3-51.
Condition to
join the tables
Credit limit must
be $10,000
FIGURE 3-51
SQL query to restrict the records in a join
Search WWH ::




Custom Search