SQL Left Outer Join Statement


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

Syntax

SELECT select_columns FROM table_name LEFT 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

Example


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

ResultSet ret = stmt.executeQuery();