Is is possible to do something like this or similar in PostgreSQL?
INSERT INTO table_2 (some_varchar_value, id_value_table_1)
VALUES ('some_varchar_value', SELECT DISTINCT id FROM table_1)
In short I want to select ids from table_1 and insert them as a second param of insert to table_2. The first of inserted values will be a const of varchar type
>Solution :
You’d use INSERT INTO ... SELECT ...:
INSERT INTO table_2 (some_varchar_value, id_value_table_1)
SELECT DISTINCT 'some_varchar_value', id
FROM table_1;