title: is it possible to insert into a table from a variable?
body: <p>Suppose i have two tables:</p>
  
  <p>Table 1 (<code>$SYSTEM.DISCOVER_SESSIONS</code>) has columns A, B, C</p>
  
  <p>Table 2 has columns A, C, D</p>
  
  <p>I query table 1 to <code>select</code> data from columns A and C</p>
  
  <p>I save that query result in a variable called: <code>$result</code></p>
  
  <p>essentially it looks like this: </p>
  
  <p><code>$result = 'SELECT [A],[C] FROM $SYSTEM.DISCOVER_SESSIONS'</code></p>
  
  <p>Now i want to <code>INSERT</code> <code>$result</code> in table 2, with columns automatically matching (A, C) since these were the ones stored in <code>$result</code></p>
  
  <p>I realized I could potentially use JOINS for this, but I am unsure how I can formulate the correct syntax for what Im trying to do. </p>
  
  <pre><code>INSERT INNER JOIN SELECT *
  INTO table2 
  FROM $result  
  </code></pre>
  
  <p>Is the approach Im trying to do possible?</p>