0
$\begingroup$

I have a question abut MySQL

I would like to handle a column with characters without changing the original DB. Below is the levels of the column named 'Maker'.

기아, 현대, BMW, VolksWagen, Porsche So there are about 10 기아s, 20 현대s, 30 BMWs and so on.

As you can see, some of them are written in Korean and others are in English. I do not want to touch English-written words. I only want to change Korean words into English.

I tried to you CASE and IF sentences like below.

SELECT
    CASE
        WHEN Maker='기아' THEN 'KIA' 
        WHEN Maker='현대' THEN 'HyunDai'
    END AS new_Maker
FROM table_name

It successfully changes KIA and HyunDai but BMW, VolksWagen, and Porsche shows as NULL. I would appreciate any advice. Thank you.

$\endgroup$
2
$\begingroup$

You haven't specified what happens for values other than '기아' ('KIA') and '현대' ('HyunDai'). Try

SELECT
CASE
    WHEN Maker='기아' THEN 'KIA' 
    WHEN Maker='현대' THEN 'HyunDai'
    ELSE Maker
END AS new_Maker

FROM table_name

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.