Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 525633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:41:33+00:00 2026-05-13T08:41:33+00:00

I have my database set up as such: Each product I have has it’s

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:41:33+00:00Added an answer on May 13, 2026 at 8:41 am

    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.

    This is why you should not be using one table per product and one table per year.

    What you need is one “Product” table and one “Transaction” table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a mysql database I have table of geographical areas where each row has
I have this database structure, SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; CREATE TABLE IF NOT EXISTS `announces` (
Let's say I have a large set of data within which each datum has
I have a database table, USER_OPTIONS, containing a field for each of a variety
Provided that I have the following result set from a mysql database table: +----+------+-------+
I have an existing table of contacts that has about 140k records in it.
I have nested set table (MySQL) with about 1.5 million records in it. The
I have a database set up with email and password, I'm trying to use
Suppose the following: I have a database set up on database.mywebsite.com , which resolves
I have an SQL database set up in which I would like to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.