update query syntax (many updates)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to do several updates on a single column within one update
query?

For example"

update table set column1=1 where xyz='a', column1=2 where xyz='b', column1=3
where xyz = 'c'

RICK
 
It is only one update to each field, but you can choose which update to do.
I realise that you are trying to do that, but I there are other readers.
something like:

IIF( xyz='a', 1, IIF( 'xyz' = "b", 2 , IIF ( xyz = 'c', 3, "something
else")))

if it really is "a", "b", "c" you are testing for and 1,2,3 you want you can
also use INSTR( "abc",[xyz])
 
David has a good answer for a limited amount of values. Either way, I would
probably create a small lookup table:

tblConversion
=================
xyz text primary key with values a, b, c
Col1 numeric with values 1, 2, 3

Create an update query with this table and your table joining the xyz
fields. Update column1 with Col1.
 

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

Back
Top