Map sequence of numbers to corresponding letters
P粉304704653
2023-08-30 16:24:23
<p>I have a <code>int</code> column that contains values no greater than 20. I want to select its corresponding uppercase letter: </p>
<pre class="brush:php;toolbar:false;">1 = A
2=B
3=C
...</pre>
<p>I don't care what happens after Z because the column does not contain larger values. Is there an easy way to convert this to single byte characters using a SQL query? </p>
Another MySQL-specific alternative uses
elt
Demo
Add 64 to the integer and you get the ASCII value of the letter you want.
Read https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char