title: How to INNER JOIN 4 tables?
body: <p>I had to create an addressbook application connecting a database to a java gui. I'm working on my search button right now and almost got it but cant figure out how to connect all four tables. I need to search by a last name and then I want it to show all related information from that person.  </p>
  
  <p><a href="https://i.stack.imgur.com/Qx9CQ.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/Qx9CQ.jpg" alt="enter image description here"></a></p>
  
  <p>So far this is what I have and it seems to be working but when I try to INNER JOIN emailAddresses and phoneNumbers I get a syntax error. </p>
  
  <pre><code>resultSet =
      statement.executeQuery( "SELECT * FROM names INNER JOIN addresses ON names.personID = addresses.personID WHERE lastName LIKE '%" + last + "%' ");
              resultSet.next();
              jTextField1.setText(resultSet.getString("firstName"));
              jTextField2.setText(resultSet.getString("lastName"));
              jTextField3.setText(resultSet.getString("address1"));
              jTextField4.setText(resultSet.getString("address2"));
              jTextField5.setText(resultSet.getString("city"));
              jTextField6.setText(resultSet.getString("state"));
              jTextField7.setText(resultSet.getString("zipcode"));
              jTextField8.setText(resultSet.getString("phoneNumber"));
              jTextField9.setText(resultSet.getString("emailAddress"));
  </code></pre>