Z
Z
zlogr2016-01-26 17:29:59
SQL
zlogr, 2016-01-26 17:29:59

Psql INSERT INTO .. ​​how to pass one value via SELECT and the rest are static?

Hello.
Stuck on the following problem...
There is a sign:
product_id | taxon_id | position
I want to make INSERT into it, and I need to get product_id via SELECT from another table, and specify taxon_id and position with static values ​​(for example, 592 and 1).
Those. if we consider INSERT with static values:

INSERT INTO products_taxons (product_id,taxon_id,position) VALUES (3500,592,1);

instead of 3500, I want to pass the values ​​from
SELECT product_id FROM table_name;
and the values ​​for taxon_id and position are always 592 and 1.
Please help with the request or indicate where to dig. In Google, I found solutions when all data is transferred by SELECT, but I did not find SELECT + static values ​​:(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksej, 2016-01-26
@zlogr

INSERT INTO products_taxons (product_id,taxon_id,position)
SELECT product_id, 592, 1 FROM table_name;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question