Heres the situation, a database was created and not normalized. The table LUT_ProductInfo contains a field called flavor that is populated with an actual flavor name (ie Coke Classic). I created a lookup table LUT_Flavors with all of the flavor names complete with PKs. I need to replace all of the flavor names in LUT_Product info with the corresponding foreign key from the LUT_Flavors table. At the moment, the flavor names in each table are identical so the swap should be clean.
I tried something like this:
update LUT_ProductInfo
set flavor =
(select LUT_Flavor.id, LUT_Flavor.flavor
from LUT_ProductInfo prod
join LUT_Flavor on LUT_Flavor.flavor = prod.flavor).ID
where
LUT_ProductInfo.flavor = (select LUT_Flavor.id,LUT_Flavor.flavor
from LUT_ProductInfo prod
join LUT_Flavor
on LUT_Flavor.flavor = prod.flavor).flavor
But that broke some rules I guess and didn’t do anything. Does anyone have any insight?
Sorry, am on the road, so no database to try this on – but try: