If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Unanswered: Update with Conditional Where

My problem is that I have tens of thousands of records in a table with multiple duplicate RegionNames (hundreds of multiples for each RegionName) -

Two tables are being accessed - The Bottle table that holds all of the wine bottle information and the Region table that hold the world wide regions for the wine. The Region Table has multiple duplicate IDs for the same region (over 500 Regions) and the Bottle Table references many if not all of these duplicates RegionIDs throughout the table.

My goal was to update the Bottle table to reflect just one RegionID for each RegionName - I will specify the RegionID that I will use in the set command - (Later, i will delete all duplicates from the Region table)

My attempt below doesnt work but in the "WHERE [RegionID] =" I was trying to get only those RegionIDs both the RegionIDs from each table Match, The RegionName is specified, and to omit all the RegionIDs that are already 3125.

If anyone has any suggestions I would be extremely grateful. (I am just working on cleaning data for a migration - I do not have much SQL experience, so be gentle if there are obvious syntax or other mistakes)

(as a normal select statement - this returns good data, but as a subquery, i get this error below:
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "Bottle.RegionID" could not be bound.
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "Region.RegionID" could not be bound.
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "Region.RegionName" could not be bound.
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "Bottle.RegionID" could not be bound.
Msg 116, Level 16, State 1, Line 5
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

Data Information:
The Region table contains only the RegionID & RegionName (This table has hundreds of duplicate RegionNames) After I update the Bottle Table, I will be deleting the duplicates from this table to reflect only One RegionName and a corresponding RegionID

The Bottle table contains all of the bottle descriptive data including the RegionID. I am updating the records in this table to contain only 1 RegionID for a corresponding RegionName.