Categories
Development

Update grouped rows with ID of newly inserted grouping row

I want to group several rows of table A and insert a new row into table B for each bunch of grouped rows.
Next to that I want to update the rows of table A with the ID of the newly inserted row.

Inserting the lines into the table with ‘grouplines’ is like:

INSERT INTO B(...,...,...)
SELECT row1, row2, row3 FROM A
GROUP BY row1,row2,row3

This will produce a list of IDs in table B. I want to update the rows of table A with the ID of the corresponding group-row of table B.

Is there a possibilty to do this?

Leave a Reply

Your email address will not be published. Required fields are marked *