Skip to content
Advertisement

Insert two or more values at once from not related tables

I want to insert at once, all values from one table’s column, with max value of another table, these tables are not connected with each other.

Let’s simplify it to the maximum, tableA consists of

tableB consist of

TableC is

Following query definitely is not going to work but I have no other idea how to solve it

INSERT INTO tablec (id, external_ids) values ((SELECT max(id) from tablea), (select id from tableb))

Of course manually inserting max value is not a solution (like select 101, id from tableb)

Extected result should be

Advertisement

Answer

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement