i need to perform a insert query for multiple rows whereby the first column is a numeric and identical value and the second values are queried from another table.
something like
insert into table (33, select col2 from another_table);
can this be accomplished with a single statement?
PostgreSQL INSERT Multiple Rows First, specify the name of the table that you want to insert data after the INSERT INTO keywords. Second, list the required columns or all columns of the table in parentheses that follow the table name. Third, supply a comma-separated list of rows after the VALUES keyword.
To perform a bulk insert you'd simply createdb and then use csvsql , which connects to your database and creates individual tables for an entire folder of CSVs.
INSERT-SELECT-UNION query to insert multiple records Thus, we can use INSERT-SELECT-UNION query to insert data into multiple rows of the table. The SQL UNION query helps to select all the data that has been enclosed by the SELECT query through the INSERT statement.
like this
insert into table
select 33, col2 from another_table;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With