I have a list of integers and I would like an INSERT that adds all of them as a specific column. The idea is that I can avoid using multiple INSERT or I can avoid using an SQL FOR LOOP.
Here's what I tried:
INSERT INTO my_table
(id, number, text)
SELECT array_id, 5, 'Text'
WHERE array_id = (SELECT 9,14,19,39,58,15,1,59,40,20,17,69,12,42,22,2,57,1,8,4)
OR
WHERE array_id IN (9,14,19,39,58,15,1,59,40,20,17,69,12,42,22,2,57,1,8,4)
And various other things,
Is there a quick way to do that?
PART B of the same question is to add combinations of Lists Like this:
INSERT INTO my_table
(id, number, text)
SELECT array_id, array_number, array_text
WHERE array_id = (SELECT 9,14,19,39,58,15,1,59,40,20,17,69,12,42,22,2,57,1,8,4)
AND array_number = (SELECT 1,2,3)
AND array_text = (SELECT 'Text A', 'Text B')
So that it creates all possible combinations of those.
If such super script exists I definitely want to know it!
EDIT:
I Think my question is similar to this here.
INSERTs inside a transaction?