title: Outer Join using multiple Google Sheets and the QUERY function
body: <p>As an example, say I have the following sheets in the same workbook of a Google Doc:</p>
  
  <pre><code> SHEET1            |   SHEET2
   \   A  |  B       |   \   A   |   B   |   C   |   D
  1|  ID  |Lookup    |  1| Lookup| Name  |Flavor | Color
  2|  123 | 4445     |  2| 1234  |Whizzer|Cherry | Red
  3|  234 | 4445     |  3| 4445  |Fizzer |Lemon  | Yellow
  4|  124 | 1234     |  4| 9887  |Sizzle |Lime   | Blue
  5|  767 | 1234     |
  6|  555 | 9887     |
  </code></pre>
  
  <p>Obviously, Google Docs isn't made with relational databases in mind, but I am trying to obtain results similar to the SQL query</p>
  
  <pre><code>SELECT
    SHEET1.ID,
    SHEET2.*
  FROM 
    SHEET1 
      LEFT JOIN
        SHEET2
      ON SHEET1.Lookup = SHEET2.Lookup
  </code></pre>
  
  <p>resulting in a table that looks like</p>
  
  <pre><code> SHEET3            
   \   A    |   B   |   C   |   D   |   E   
  1|   ID   |Lookup | Name  |Flavor | Color
  2|  123   | 4445  |Fizzer |Lemon  | Yellow
  3|  234   | 4445  |Fizzer |Lemon  | Yellow
  4|  124   | 1234  |Whizzer|Cherry | Red
  5|  767   | 1234  |Whizzer|Cherry | Red
  6|  555   | 9887  |Sizzle |Lime   | Blue
  </code></pre>
  
  <p>but this is where I stand currently</p>
  
  <pre><code> SHEET3            
   \   A    |   B   |   C   |   D   |   E   
  1|        |       |       |       |
  2|  123   | 4445  | #N/A  |       |
  3|  234   | 4445  |       |       |
  4|  124   | 1234  |       |       |
  5|  767   | 1234  |       |       |
  6|  555   | 9887  |       |       |
  </code></pre>
  
  <p>At the moment I have managed to use the <code>QUERY</code> function to grab the values from <code>SHEET1</code> and have tried a few different <code>QUERY</code> functions in <code>SHEET3!C1</code> in an attempt to "<code>LEFT JOIN</code>" the two sheets using <a href="http://the-byting-experience.blogspot.com/2011/10/google-spreadsheet-as-database.html" rel="noreferrer">this blog post</a> as a reference. At this point, the two functions I am using are as follows.</p>
  
  <p><code>SHEET3!A2=QUERY(SHEET1!A2:B20, "SELECT A,B")</code><br>
  <code>SHEET3!C2=QUERY(SHEET2!A2:E20, "SELECT B,C,D WHERE A="""&amp;B2&amp;"""")</code></p>
  
  <p>and hovering over the error in <code>C2</code> reads "Query completed with an empty output". How can I join these sheets?</p>
  
  <p>Additional references:<br>
  <a href="https://support.google.com/docs/answer/3093343?hl=en" rel="noreferrer">Google Docs syntax page for QUERY</a></p>