,ch03.13605 Page 136 Wednesday, November 29, 2000 4:42
,ch03.13605 Page 137 Wednesday, November 29, 2000 4:42 PM Right [Outer] Join Specifies that all records be returned from the table on the right side of the join statement, even if the table on the left has no matching record. Columns from the left table return NULL values. (In the example, all records in the jobs table are returned with or without a matching record in the employee table (currently supported by Microsoft SQL Server): — Oracle theta style SELECT e.emp_id, e.fname, e.lname, j.job_desc FROM employee e, jobs j WHERE j.job_id = (+) e.job_id — ANSI style SELECT e.emp_id, e.fname, e.lname, j.job_desc FROM employee e RIGHT JOIN jobs j ON e.job_id = j.job_id Full Join Specifies that all rows from either table be returned, regardless of matching records in the other table. The result set shows NULL values where no data exists in the join (currently supported by Microsoft SQL Server): — theta style does not support this — function — ANSI style SELECT e.emp_id, e.fname, e.lname, j.job_desc FROM employee e FULL JOIN jobs j ON e.job_id = j.job_id Joins in the ANSI style are actually easier to understand than those in theta style, since the query itself clearly indicates which table is on the left in a LEFT JOIN and which table is on the right in a RIGHT JOIN. The syntax to perform a similar query with multipart keys and multiple tables joined together is largely an extension of the same technique. Multi-table Join Example –theta style query with multiple tables SELECT a.au_lname, a.au_fname, t2.title FROM authors a, titleauthor t1, titles t2 Statements SELECT 137
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services