How to Combine Files and Create a New Data Table in MySQL

How to Combine Files and Create a New Data Table in MySQL


In my previous post, I introduced how to combine multiple files into one using Access, and now I’ll explain how to do the same using MySQL. The SQL code is similar in both programs, so the code will be the same.

First, I uploaded three different datasets to MySQL, and I want to combine them into one.

I’ll use union code to combine all data.

SELECT * FROM code_test.`2018`
UNION
SELECT * FROM code_test.`2019`
UNION
SELECT * FROM code_test.`2020`;


Now I want to create this data table. So, I’ll use this code.

CREATE TABLE code_test.combined_data AS
SELECT * FROM code_test.`2018`
UNION
SELECT * FROM code_test.`2019`
UNION
SELECT * FROM code_test.`2020`;

SELECT * FROM code_test.combined_data

Now, new data table named ‘combined_data’ was created.


We aim to develop open-source code for agronomy ([email protected])

© 2022 – 2025 https://agronomy4future.com – All Rights Reserved.

Last Updated: 28/02/2025

Your donation will help us create high-quality content.
PayPal @agronomy4furure / Venmo @agronomy4furure / Zelle @agronomy4furure

Comments are closed.