title: How to do sub-query correctly while selecting two tables in Oracle?
body: <p>I need to do a sub-query from a table to find all employees working in the same department that is part of the same city, but I'm not getting it.</p>
  
  <p>I have the following tables:</p>
  
  <p><strong>Table departments</strong></p>
  
  <pre><code>DEPARTMENTS
  
  department_id
  department_name
  location_id
  </code></pre>
  
  <p><strong>Table locations</strong></p>
  
  <pre><code>LOCATIONS
  
  location_id
  street_address
  postal_code
  city
  state_province
  country_id
  </code></pre>
  
  <p><strong>Table employees</strong></p>
  
  <pre><code>EMPLOYEES
  
  employee_id
  first_name
  last_name
  email
  phone_number
  hire_date
  job_id
  department_id
  </code></pre>
  
  <p>My code right now is something like that :</p>
  
  <pre><code>SELECT
      firt_name,
      department_id,
      job_id
  FROM employees
  WHERE state_province = (SELECT state_province FROM locations
                          WHERE state_province = 'Sao Paulo');
  </code></pre>
  
  <p>The problem is that while I want to select <code>state_province</code> from the table <code>locations</code>, I can't select the name, department id and job id from the table <code>employees</code>. How can I select both tables while doing the sub-query ?</p>
  
  <p>Anyway, sorry if I did something wrong in the code, I am new to sub-queries.</p>