How to merge data from two SQL tables into one table?

You can merge data from two tables by using the JOIN operation in SQL. Here is a simple example:

Suppose there are two tables, one named “table1” with columns “id” and “name”, and the other named “table2” with columns “id” and “age”.

To combine the data from these two tables, you can use the following SQL statement:

SELECT table1.id, table1.name, table2.age
FROM table1
JOIN table2
ON table1.id = table2.id;

This SQL statement will join “table1” and “table2” based on their “id” fields, and then return a new table that includes the “id”, “name”, and “age” fields.

Leave a Reply 0

Your email address will not be published. Required fields are marked *