SQL Virtual Table

ms-accessms-access-2003sql

I have my database set up as such:

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")

ex) p-backScratcher (where p- is indicative of "product")

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"

ex) sales-2008, sales-2009, etc. etc.

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.

So for example, I'd want to query all transactions for "p-backScratcher", I don't want to have to type out

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

…but rather:

SELECT sales.date 
  FROM sales 
 WHERE sales.transactionID = p-backScratcher.transactionID

Best Answer

In SQL, as Kyle's answer states, you can create a View, which is a kind of Virtual table, but I would strongly recommend that you get a book, or google, Relational database design, before you commit yourself to a database structure.