title: Why doesn't this SQL code work using a simple predicate in a WHERE EXISTS construction?
body: <p>I am working on a sample database to learn SQL as part of a class. One task was &quot;List names of employees who are managers using EXISTS&quot;. (I already completed the assignment, so it is okay to get an answer here).</p>
  <p>I originally used this:</p>
  <pre><code>SELECT `FIRSTNAME`
       , `MIDINIT`
       , `LASTNAME` 
    FROM `emp` 
   WHERE EXISTS (SELECT * FROM `emp` WHERE `JOB`='MANAGER')
  </code></pre>
  <p>However, it simply would not work.</p>
  <p>It kept showing the names of ALL employees in the <code>emp</code> table instead of the 7 where <code>JOB</code>='MANAGER'.</p>
  <p>Here is the weird part.</p>
  <p>When I just run</p>
  <pre><code>(SELECT * FROM `emp` WHERE `JOB`='MANAGER')
  </code></pre>
  <p>it works to show just the 7 rows where employees are managers.
  <a href="https://i.stack.imgur.com/mqd6a.png" rel="nofollow noreferrer">results showing just the rows where JOB = 'MANAGER'</a></p>
  <p>So, why doesn't it work as the WHERE EXISTS predicate?</p>
  <p>In order to get it to work, I had to do this:
  SELECT <code>FIRSTNAME</code>, <code>MIDINIT</code>, <code>LASTNAME</code> FROM <code>emp</code> WHERE EXISTS (SELECT * FROM <code>dept</code> WHERE <code>emp</code>.<code>EMPNO</code>=<code>dept</code>.<code>MGRNUMBER</code>)
  I had to compare EMPNO in the <code>emp</code> table with MGRNUMBER in the <code>dept</code> table. I do not understand why I had to go to another table to compare values.</p>