Home > Blockchain >  Guide me in understanding the logic used in SQL query
Guide me in understanding the logic used in SQL query

Time:07-07

SELECT 
    CASE 
        WHEN REGEXP_SUBSTR(purchaser_id, '[a-z]') IS NOT NULL 
            THEN NULL 
            ELSE purchaser_id 
    END AS s_purchaser_id
FROM 
    table1;

Does this mean if there is any alpha-numeric value it will replace to NULL?

Thanks!

CodePudding user response:

The logic says that if a purchaser_id contain a lowercase letter, the s_purchaser_id output will be NULL, otherwise the output will be just be the same purchaser_id.

Some samples:

purchaser_id | s_purchaser_id
ABC          | ABC
abc          | NULL
ABCabc       | NULL
  • Related