Update Query

H

Haole

I have a table that has a number data field. In this field the allowable
numbers are between 0 and 3.

I want to run an update query which "reverses" the numbers for example if
the current number is 3 then I want to update it so it is 0.

Since the allowable numbers are 0, 1, 2, 3 I would need an update query to
do the following: 3=0, 2=1, 1=2, and 0 = 3.
 
J

John Spencer

3 - Current value will give you the reverse of the numbers from 0 to 3.

Your update would look like

UPDATE YourTable
Set YourField = 3-[YourField]
WHERE YourField is Not Null



'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
L

Lord Kelvan

you are not doing a mass update i take it just on a specific record

UPDATE mytable
SET mytable.myfield = Switch([myfield]= 0,3,[myfield]=3,0,[myfield]=
2,1,[myfield]=1,2)
WHERE mytable.primarykey = avalue

hope this helps

regards
kelvan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top