Skip to content
Advertisement

Replace NULL values with values from join results

I have a table where the value of a column can be NULL because those records have been created in the past. But now I would like to update those records. The tables are as follows:

It’s a MySQL database.
In TABLE1 I would like to update all the NULL values for workflowId with the actual workflow with the result of the query:

Another thing to notice is that TABLE1 is much bigger than TABLE2, and executing that join for each record in TABLE2 has a big cost. Ideally, I would like also to reduce the computational costs in parsing all the records in TABLE1, see if they have correspondences in TABLE2 and to update them (as opposite of executing that join for each record in TABLE2).
However, as long as I can find something that works for my case I would be happy.

Advertisement

Answer

You seem to want an update with join:

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