title: SQL Virtual Table
body: <p>I have my database set up as such:</p>
  
  <p>Each product I have has it's own table where it records the quantity sold/transaction # (so column 1 is "transactionID", column 2 is "quantity")</p>
  
  <p>ex) p-backScratcher (where p- is indicative of "product")</p>
  
  <p>There are also tables for each year which hold records of each transaction that went through.  Each of these tables holds the following columns: "transactionID", "date", "time", "pt_CA", "pt_DB", "pt_VC", "pt_MC", "pt_CH", "pt_AM"</p>
  
  <p>ex) sales-2008, sales-2009, etc. etc.</p>
  
  <p>I'd like to be able to reference a single table that holds all the records for each year without having to change the sql for the table to include a new year.</p>
  
  <p>So for example, I'd want to query all transactions for "p-backScratcher", I don't want to have to type out</p>
  
  <pre><code>SELECT sales-2008.date, sales-2009.date 
    FROM sales-2008, sales-2009 
   WHERE sales-2008.transactionID = p-backScratcher.transactionID 
      OR sales-2009.transactionID = p-backScratcher.transactionID
  </code></pre>
  
  <p>...but rather:</p>
  
  <pre><code>SELECT sales.date 
    FROM sales 
   WHERE sales.transactionID = p-backScratcher.transactionID
  </code></pre>