I have a query which is working properly:
INSERT INTO t1 (COL_1, COL_2, COL_3)
SELECT COL_1, 'external value', COL_3
FROM t2
WHERE COL_4 IN ('1', '2', '3', '4')
So, ‘external value’ goes to each row in t1.
The question is: How can I add different ‘external value’ to rows? For example, the first row has ‘ext val 1’, the second row has ‘ext val 2’ and so on…
Is there any solution to this approach?
THX.
Currently, I have no any idea for INSERT INTO SELECT
, but if possible I do not want to switch to INSERT INTO VALUES
… Additional info, the target DB is MYSQL.
2
Answers
fiddle
The values can be provided in any other rowset form – for example, as an output of JSON_TABLE function.