How to Insert a new record in new table for each row in existing table
Briefly

Instead of adding new columns for each year's subscription amount in a customer subscriptions table, a better approach would be to create a new table that records each year's subscription as a separate row. This method enhances data organization, enabling historical tracking of subscription trends without modifying the original table structure. By utilizing SQL's INSERT INTO...SELECT statement with appropriate transformation methods, you can effectively populate the new table with existing data, thereby maintaining efficient database design while accommodating future growth in subscription data.
In order to manage your customers' subscriptions more efficiently, you can create a new table that stores subscription information over the years, rather than adding new columns to the existing table. This allows for better scalability and easier data management.
Using a structured approach, you can insert subscriptions into the new table where each subscription amount for every year is stored as a separate row in a format that includes the customer ID, year, and subscription amount.
To achieve this, consider using an INSERT INTO...SELECT statement that aggregates current subscription data into the new table, transforming column data into row format using a UNION ALL or other appropriate SQL methods.
This new structure not only simplifies your database schema but also paves the way for easier reporting and querying of subscription trends over time.
Read at SitePoint Forums | Web Development & Design Community
[
|
]