Home | Previous Page | Next Page   Appendix B. Demonstration SQL > SQL Files for the Relational Database Model >

sel_ojoin1.sql

The following example command file uses a simple outer join on two tables. The use of the keyword OUTER in front of the cust_calls table makes it the subservient table. An outer join causes the query to return information on all customers, even if they do not make calls to customer service. All rows from the dominant customer table are retrieved, and null values are assigned to corresponding rows from the subservient cust_calls table.

SELECT c.customer_num, c.lname, c.company, 
     c.phone, u.call_dtime, u.call_descr
   FROM customer c, OUTER cust_calls u
   WHERE c.customer_num = u.customer_num;
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]