Skip to content
Advertisement

Import values from temporary table to another table?

I’m joining 3 tables:

JavaScript

Currently, I’m fetching the data, build a new array and insert it into my final table.

JavaScript

However, I wonder if it’s possible to do this in one go, so basically directly from the temporary table?

Advertisement

Answer

Yes. Use INSERT . . . SELECT:

JavaScript

Note that I introduced table aliases. These make the query easier to write and to read. And IN is easier to follow than repeated OR conditions.

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