Using a Right Outer Join
A right outer join retrieves all rows from the right table in a join, and only those rows from the left table that match the search condition specified in the
ON clause. The following right outer join retrieves a list of rivers and their countries of origin, but also reports those countries that are not the source of any river:
EXEC SQL DECLARE RIVSOURCE CURSOR FOR SELECT R.RIVER, C.COUNTRY FROM RIVERS.R RIGHT JOIN COUNTRIES C ON C.COUNTRY = R.SOURCE ORDER BY C.COUNTRY;
- Tip: Most right outer joins can be rewritten as left outer joins by reversing the order in which tables are listed.