This is a small post describing the PostgreSQL query for inserting data into a table using Select Query, as I had to use it for solving some issue in one of my projects. So, the query is below :
INSERT INTO films (code, title, did, date_prod, kind) VALUES ('T_601', (SELECT title from FilmCode where id = 'T_601') ,
106, '1961-06-16', 'Drama');
So, what you have to basically do is to put the ‘Select’ query in round brackets () and execute the query [ The brackets are the main thing to watch out for, as, otherwise the query will give an error on execution.]. The required value will be fetched from the source table and inserted into the desired table.
Hope this helps 🙂