Reputation: 1072
Is there any way in MySQL to return a character when I give integer as input?
For example
Value Returns
-----------------
1 A
2 B
3 C
4 D
Upvotes: 0
Views: 110
Reputation: 9104
You could use SELECT char(int)
, but please note it will only work for 27 characters, before returning [ \ ] ^
since it's using the character codes from the ASCII table
SELECT char(64 + table.column) FROM table;
Upvotes: 1
Reputation: 17048
You can use the ascii values:
select CHAR(1 + 64);
^ that's your 1..26
Upvotes: 0