title: How to join 2 MySQL Tables without returning all joined rows
body: <p>I have 2 tables that I want to join and all I want to know from the joined table is whether there is an exiting row that matches the join condition. I do not want to return all rows the the joined table.</p>
  
  <p>Example:</p>
  
  <pre><code>Table A
  ID Name
  1  Bob
  2  Sally
  3  Joe
  
  Table B
  Num ID Data
  1   1  anything
  2   1  some more
  3   3  thats it
  </code></pre>
  
  <p>What I want it to return all rows from table A but all I care to know is whether there is a matching ID on table B. I do not want to return all matching rows.</p>
  
  <p>So my output would look something like this:</p>
  
  <pre><code>ID Name  Has Data
  1  Bob   Yes
  2  Sally No
  3  Joe   Yes
  </code></pre>
  
  <p>I do not want the output to look like this (which it currently does):</p>
  
  <pre><code>ID Name  Has Data
  1  Bob   Yes
  1  Bob   Yes
  2  Sally No
  3  Joe   Yes
  </code></pre>
  
  <p>Here is my query:</p>
  
  <pre><code>  SELECT a.ID, Name
    FROM table_a AS a
    LEFT JOIN (SELECT DISTINCT b.ID FROM table_b) AS b ON b.ID = a.ID
  </code></pre>
  
  <p>I get this error message:
  Unknown column 'b.ID' in 'field list'</p>