SQL Inner Join Statement


Performs a join where all records in the left table and right table must match the join criteria.

Syntax

SELECT select_columns FROM table_name INNER 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 from persons
    inner join Memberships on persons.id = Memberships.PersonId where persons.id<5  order by persons.id desc");

ResultSet ret = stmt.executeQuery();