Skip to content
Advertisement

Populating Bridge tables

Hello I have a bridge table that has these two columns only to carry the IDs from other dim tables I’m wondering how can I populate this bridge table and make it related because a simple insert into a statement won’t match the productId to the correct SupplierID

enter image description here

Advertisement

Answer

Use joins:

select p.productid, s.supplierid
from stageTable st join
     products p
     on st.product = p.product join
     suppliers s
     on st.suppliername = s.suppliername;

You can put insert into . . . before this for the insert.

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