title: Using a nested select query in Oracle 11g
body: <p>I'm trying to use a nested select and have it display rows with a patients first name patients last name and their email.</p>
  
  <p>What I want to use is this:</p>
  
  <pre><code>select pat_first, pat_last, pat_email
  from (select pat_id
    from patients
  minus
    select pat_allergies_id_fk
    from patient_allergies);
  </code></pre>
  
  <p>However the patients table has pat_id, pat_first, pat_last, and pat_email. The Patient_allergies table only has patient_allergies_id_fk and patient_allergies columns. If I put the tables that I want into the first of the inner selects like:</p>
  
  <pre><code>select pat_first, pat_last, pat_email
  from (select pat_id, pat_first, pat_last, pat_email
    from patients
  minus
    select pat_allergies_id_fk
    from patient_allergies);
  </code></pre>
  
  <p>but it gives an error - "ORA-01789: query block has incorrect number of result columns". I figure it's because I'm trying to do a minus from a table with 5 columns and subtracting a table of two columns, but I'm not sure how I can get the query to display my desired columns (pat_first, pat_last, and pat_email).</p>
  
  <p>For example, the patients table has 50 rows, and the patient_allergies table has 15, I'm trying to get those 35 rows not in patient_allergies and have the pat_first, pat_last, and pat_email rows outputted.</p>