msinfo
msinfo

Reputation: 1175

Access 2007 Update Query with multiple criterias on single column

Col1 . . . . .Col2
AA
BB
CC
AA
BB
CC

I need to update Col2, keeping in mind following conditions.

If Col1 = AA, then Col2 = A 
If Col1 = BB, then Col2 = B
If Col1 = CC, then Col2 = C

I went through Build option and in functions, could see, IIF, Switch, and Choose, but can't understand how can I use them, for constructing a query, with multiple criteria.

Thanks for time.

Upvotes: 2

Views: 161

Answers (1)

Arion
Arion

Reputation: 31239

You could do this:

UPDATE table1
SET Col2=
(
    Switch 
    ( 
        Col1 = 'AA', 'B', 
        Col1 = 'BB', 'B', 
        Col1 = 'CC', 'C',
        true,'Unknowed'
    )
)

Reference:

Upvotes: 1

Related Questions