View Single Post
  #4  
Old March 5th, 2006, 10:25 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default Update field based on current value

Create a table with the old values and the new values.

Then link that table to the existing table on the existing value to the old
value.

Now make an update the updates the fields to the new value

An SQL statement would look like the following.

UPDATE TableOriginal INNER JOIN TableNewValues
ON TableOriginal.TheField = TableNewValues.TheOldValues
SET TheField = TableNewValues.TheNewValues

Amy Blankenship wrote:

IIF(tblName[FieldName] ='abc', '123', IIF(tblName[FieldName] = 'bcd', '234',
IIF(tblName[FieldName] = ...etc...)))

HTH;

Amy

"JR" wrote in message
oups.com...
I need to update all values in a database column to new values. The
way it works is basically:

if = abc replace with 123
if = bcd replace with 234
if = cde replace with 345
if = def replace with 456

Now the values used above are just for example it's not really pattern
orientated. I can create four update queries for this, however was
hoping there was a way to do this in one shot. Is there a single
update query that could update the source values with new values based
on rules like the above?

Thanks.

JR