title: How to write this SQL query as a JPA query
body: <p>I have this query that is running successfully in mysql but I am trying to write it as a JPA query and I keep getting errors. Here are my tables. </p>
  
  <pre><code>Table 1: business_accounts{id, business_name}
  Table 2: work_locations{location_id, name, contractor_id }
  //contractor_id on Table2 is the foreign key matched to id on table 1.
  </code></pre>
  
  <p>My sql query is that I want to return all values of business_name where id from table 1 equals contractor_id from table 2 and where name="Dublin" Here is my sql query that is working in mysql:</p>
  
  <pre><code>SELECT b.business_name FROM work_locations w 
  inner join business_accounts b on b.id=w.contractor_id where name="Carlow"
  </code></pre>
  
  <p>And here is the approach that I am taking in JPA that isn't working. Any suggestions are appreciated. Thanks</p>
  
  <pre><code>    String countyName="Dublin";
  
          Query myQuery2 = em.createQuery("SELECT b FROM business_accounts b join "
                  + "w where b.id=w.contractor_id and w.name=:countyName");
  
          myQuery2.setParameter("countyName", countyName);
  </code></pre>