Skip to content
Advertisement

Select integer column as corresponding letter of the alphabet

I have an int column that contains values no larger than about 20. I want to select as its corresponding upper case letter of the alphabet:

I don’t care what happens after Z because the column doesn’t contain larger values. Is there a simple way to do this with a SQL query, to convert to a single-byte character like this?

Advertisement

Answer

Add 64 to your integer and you have the ASCII value of the letter you want.

Read https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement