I want to insert the id of one table into another in PostgreSQL. First I want to select the id of table1 where it equals a specific value and store that into a variable. In MySQL I can do:
SET @last_id_in = (SELECT id FROM table1 WHERE col1 = 1);
Then I can insert where the value would equal @last_id_in. How can I do something similar in PostgreSQL?