Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can choose data from the initial table using a SELECT statement and then use it as a parameter in the second table by using it in an INSERT statement. Here is an example:

Assuming you have two tables named "initialtable" and "secondtable" with the following structures:

initial_table: id | name | age ---|------|---- 1 | John | 25 2 | Jane | 30

secondtable: id | personid | salary ---|-----------|------- 1 | | 2 | |

You can choose the data from the "initialtable" and insert it as a parameter in the "secondtable" using the following SQL query:

INSERT INTO second_table (person_id, salary)
SELECT id, 50000 FROM initial_table
WHERE age > 25;

This query will insert a new record in the "secondtable" with the personid of the record from the "initial_table" where age is greater than 25 and a salary of 50000.

Note: You can replace the WHERE clause with any other condition you want to choose the data from the "initial_table".