@daisha
To insert values from two tables into one in PostgreSQL, you can use the INSERT INTO SELECT statement. Here's an example:
Assuming you have two tables table1 and table2 with columns col1 and col2 respectively, and you want to insert values from both tables into a new table called combined_table with columns col1 and col2, you can use the following SQL query:
1 2 3 4 |
INSERT INTO combined_table (col1, col2) SELECT col1, col2 FROM table1 UNION SELECT col1, col2 FROM table2; |
In this query:
After running this query, the values from both table1 and table2 will be inserted into the combined_table.