「Oracle」CASE式にワイルドカードを使うサンプル

書式
カラム = case when カラム like 'xxx%’
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
UPDATE
USER_TBL
SET
UID = CASE
WHEN UID LIKE 'D9%' THEN '10001'
WHEN UID LIKE 'E8%' THEN '20002'
WHEN UID LIKE 'F8%' THEN '30003'
ELSE 'bad data'
END
UPDATE USER_TBL SET UID = CASE WHEN UID LIKE 'D9%' THEN '10001' WHEN UID LIKE 'E8%' THEN '20002' WHEN UID LIKE 'F8%' THEN '30003' ELSE 'bad data' END
UPDATE
      USER_TBL
SET
      UID = CASE
            WHEN UID LIKE 'D9%' THEN '10001'
            WHEN UID LIKE 'E8%' THEN '20002'
            WHEN UID LIKE 'F8%' THEN '30003'
            ELSE 'bad data'
      END

 

Oracle

Posted by arkgame