0

I'm trying to select an integer field as text but I have no idea how to do it.

The 1 represents low, the 2 represents medium, and 3 represents hi.

3 Answers 3

3

you can do this with CASE WHEN

SELECT (CASE WHEN column = 1 THEN "low"
             WHEN column = 2 THEN "medium"
             WHEN column = 3 THEN "high"
        END) AS value
FROM table_name;
Sign up to request clarification or add additional context in comments.

Comments

2
SELECT CASE intfield
        WHEN 1 THEN 'low'
        WHEN 2 THEN 'medium'
        WHEN 3 THEN 'hi'       
    END AS inttext
FROM table

Comments

2
Select 
CASE WHEN field = 1 then 'low' 
WHEN field = 2 then 'medium'
WHEN field = 3 then 'hi'
END as Col
from yourtable;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.