title: Inner join 2 tables into one
body: <p>I have 2 tables, trying to <code>inner join</code> into one table. I am using Excel to query, so it has limited syntax (Jet Access). <code>stack1</code> and <code>stack2</code> tables are identical and in two different Excel sheets.</p>
  
  <p>The tables come from Vertica (<code>stack1</code> and <code>stack2</code>) and SQL Server (<code>overflow</code>), then I am trying an internal query to combine the tables.</p>
  
  <p>Here is what I have tried, I am getting a syntax error on this, not sure where I am going wrong:</p>
  
  <pre><code>select *
  from [stack1$], [stack2$]
  INNER JOIN [overflow$]
  ON [stack1$].[iddate] = [overflow$].[iddate]
  AND [stack1$].[idbusiness] = [overflow$].[idbusiness]
  AND [stack2$].[iddate] = [overflow$].[iddate]
  AND [stack2$].[idbusiness] = [overflow$].[idbusiness]
  </code></pre>
  
  <p>If I do just one table like so, it works fine:</p>
  
  <pre><code>select *
  from [stack1$]
  INNER JOIN [overflow$]
  ON [stack1$].[iddate] = [overflow$].[iddate]
  AND [stack1$].[idbusiness] = [overflow$].[idbusiness]
  </code></pre>
  
  <p>Sample data:</p>
  
  <p>Overflow:</p>
  
  <pre><code> +----------+------------+---------+
  |  iddate  | idbusiness | otherid |
  +----------+------------+---------+
  | 20180209 |   95971462 |    5235 |
  +----------+------------+---------+
  </code></pre>
  
  <p>Stack 1:</p>
  
  <pre><code>+------------+-------+----------+
  | idbusiness | value |  iddate  |
  +------------+-------+----------+
  |   95971462 |       | 20180209 |
  |   95971462 |       | 20180209 |
  |   95971462 |       | 20180209 |
  |   95971462 |       | 20180209 |
  |   95971462 |       | 20180209 |
  |   95971462 |       | 20180209 |
  |   95971462 |       | 20180209 |
  |   95971462 | 10.04 | 20180209 |
  +------------+-------+----------+
  </code></pre>
  
  <p>The above query gives me:</p>
  
  <pre><code>+--------------------+-------+----------------+---------+
  | stack1$.idbusiness | value | stack1$.iddate | otherid |
  +--------------------+-------+----------------+---------+
  |           95971462 |       |       20180209 |    5235 |
  |           95971462 |       |       20180209 |    5235 |
  |           95971462 |       |       20180209 |    5235 |
  |           95971462 |       |       20180209 |    5235 |
  |           95971462 |       |       20180209 |    5235 |
  |           95971462 | 10.04 |       20180209 |    5235 |
  |           95971462 |       |       20180209 |    5235 |
  |           95971462 |       |       20180209 |    5235 |
  +--------------------+-------+----------------+---------+
  </code></pre>
  
  <p>Now I want to add <code>Stack 2</code> to this, which will contain the same columns as <code>stack1</code> but different <code>idbusiness</code> then in <code>stack1</code>. Also looks like <code>iddate</code> is not needed, all records are the same date.</p>