title: Oracle: Check if rows exist in other table
body: <p>I've got a query joining several tables and returning quite a few columns.</p>
  
  <p>An indexed column of another table references the PK of one of these joined tables. Now I would like to add another column to the query that states if at least one row with that ID exists in the new table.</p>
  
  <p>So if I have one of the old tables</p>
  
  <pre><code>ID
   1
   2
   3
  </code></pre>
  
  <p>and the new table</p>
  
  <pre><code>REF_ID
  1
  1
  1
  3
  </code></pre>
  
  <p>then I'd like to get</p>
  
  <pre><code>ID   REF_EXISTS
   1            1
   2            0
   3            1
  </code></pre>
  
  <p>I can think of several ways to do that, but what is the most elegant/efficient one?</p>
  
  <hr>
  
  <p><strong>EDIT</strong>
  I tested the performance of the queries provided with 50.000 records in the old table, every other record matched by two rows in the new table, so half of the records have REF_EXISTS=1.</p>
  
  <p>I'm adding average results as comments to the answers in case anyone is interested. Thanks everyone!</p>