Microsoft Access – Case Query

There is no CASE … WHEN in Access SQL. You can use the Switch Function instead.

UPDATE HAI
SET REGION = Switch(
    NUMREG Like '*1', 'BDG',
    NUMREG Like '*2', 'JKT',
    NUMREG Like '*3', 'KNG'
    );

That query uses Access’ default (ANSI 89 mode) * instead of % wildcard character. If you want to use the % wildcard, you can do it with the ALike comparison operator.

UPDATE HAI
SET REGION = Switch(
    NUMREG ALike '%1', 'BDG',
    NUMREG ALike '%2', 'JKT',
    NUMREG ALike '%3', 'KNG'
    );

Leave a Comment