Skip to content
Advertisement

SQL Insert into with join and where

I have three tables. For example:

  1. newTable:

  2. oldTable:

  3. associativeTable:

What I want to do now is: I want to move the name column from oldTable to newTable. I have already altered newTable and added an empty name column. Now I’m trying to write a correct INSERT INTO statement. What I have so far is:

I’m a bit lost on it. I was writing INSERT INTO statements before but never when I had an associative table. How would a correct statement look for my case?

Advertisement

Answer

A way to do it would be using a subquery in the SET part:

See db<>fiddle

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