SQL Right Outer Join Statement

Performs a join where all records in the right table are returned. If there is no matching record on the left then null is returned for the left side.


SELECT select_columns FROM table_name RIGHT OUTER JOIN join_table ON join_criteria
join_table:   table to join with
join_criteria:   where clause that specifies how records must match between the tables


PreparedStatement stmt = conn.prepareStatement(
    "select persons.id, persons.socialsecuritynumber, memberships.personId, memberships.membershipname from persons
    right outer join Memberships on persons.id = Memberships.PersonId where persons.id<2  order by persons.id desc");

ResultSet ret = stmt.executeQuery();