MySQL: ASCII Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL ASCII Function

In this guide, we will explain how to use the MySQL ASCII function with syntax and examples.

Description

The MySQL ASCII function returns the numeric value of the left-most character of a string.

Syntax

The syntax for the ASCII function in MySQL is:

ASCII( single_character )

Parameters or Arguments

single_characterThe specified character to retrieve the NUMBER code for. If more than one character is entered, the ASCII function will return the value for the first character and ignore all of the characters after the first.

Applies To

The ASCII function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some MySQL ASCII function examples and explore how to use the ASCII function in MySQL.

For example:

mysql> SELECT ASCII('t');
Result: 116

mysql> SELECT ASCII('adglob.in');
Result: 116

mysql> SELECT ASCII('T');
Result: 84

mysql> SELECT ASCII('T2');
Result: 84

A listing of the ASCII values

ASCII (which stands for American Standard Code for Information Interchange) is a character encoding standard for text files in computers and other devices. ASCII is a subset of Unicode and is made up of 128 symbols in the character set. These symbols consist of letters (both uppercase and lowercase), numbers, punctuation marks, special characters and control characters. Each symbol in the character set can be represented by a Decimal value ranging from 0 to 127, as well as equivalent Hexadecimal and Octal values.

The following is a listing of ASCII values displaying the Decimal, Hexadecimal, Octal and Character values for each ASCII character.

Standard ASCII Characters

DecHexOctCharDescription
000000^@Null (NUL)
101001^AStart of heading (SOH)
202002^BStart of text (STX)
303003^CEnd of text (ETX)
404004^DEnd of transmission (EOT)
505005^EEnquiry (ENQ)
606006^FAcknowledge (ACK)
707007^GBell (BEL)
808010^HBackspace (BS)
909011^IHorizontal tab (HT)
100A012^JLine feed (LF)
110B013^KVertical tab (VT)
120C014^LNew page/form feed (FF)
130D015^MCarriage return (CR)
140E016^NShift out (SO)
150F017^OShift in (SI)
1610020^PData link escape (DLE)
1711021^QDevice control 1 (DC1)
1812022^RDevice control 2 (DC2)
1913023^SDevice control 3 (DC3)
2014024^TDevice control 4 (DC4)
2115025^UNegative acknowledge (NAK)
2216026^VSynchronous idle (SYN)
2317027^WEnd of transmission block (ETB)
2418030^XCancel (CAN)
2519031^YEnd of medium (EM)
261A032^ZSubstitute (SUB)
271B033^[Escape (ESC)
281C034^\File separator (FS)
291D035^]Group separator (GS)
301E036^^Record separator (RS)
311F037^_Unit separator (US)
3220040Space
3321041!Exclamation mark
3422042Quotation mark/Double quote
3523043#Number sign
3624044$Dollar sign
3725045%Percent sign
3826046&Ampersand
3927047Apostrophe/Single quote
4028050(Left parenthesis
4129051)Right parenthesis
422A052*Asterisk
432B053+Plus sign
442C054,Comma
452D055Hyphen/Minus
462E056.Full stop/Period
472F057/Solidus/Slash
48300600Digit zero
49310611Digit one
50320622Digit two
51330633Digit three
52340644Digit four
53350655Digit five
54360666Digit six
55370677Digit seven
56380708Digit eight
57390719Digit nine
583A072:Colon
593B073;Semicolon
603C074<Less-than sign
613D075=Equal/Equality sign
623E076>Greater-than sign
633F077?Question mark
DecHexOctCharDescription
6440100@Commercial at/At sign
6541101ALatin capital letter A
6642102BLatin capital letter B
6743103CLatin capital letter C
6844104DLatin capital letter D
6945105ELatin capital letter E
7046106FLatin capital letter F
7147107GLatin capital letter G
7248110HLatin capital letter H
7349111ILatin capital letter I
744A112JLatin capital letter J
754B113KLatin capital letter K
764C114LLatin capital letter L
774D115MLatin capital letter M
784E116NLatin capital letter N
794F117OLatin capital letter O
8050120PLatin capital letter P
8151121QLatin capital letter Q
8252122RLatin capital letter R
8353123SLatin capital letter S
8454124TLatin capital letter T
8555125ULatin capital letter U
8656126VLatin capital letter V
8757127WLatin capital letter W
8858130XLatin capital letter X
8959131YLatin capital letter Y
905A132ZLatin capital letter Z
915B133[Left square bracket
925C134\Reverse solidus/Backslash
935D135]Right square bracket
945E136^Circumflex accent/Caret
955F137_Underscore/Low line
9660140`Grave accent
9761141aLatin small letter a
9862142bLatin small letter b
9963143cLatin small letter c
10064144dLatin small letter d
10165145eLatin small letter e
10266146fLatin small letter f
10367147gLatin small letter g
10468150hLatin small letter h
10569151iLatin small letter i
1066A152jLatin small letter j
1076B153kLatin small letter k
1086C154lLatin small letter l
1096D155mLatin small letter m
1106E156nLatin small letter n
1116F157oLatin small letter o
11270160pLatin small letter p
11371161qLatin small letter q
11472162rLatin small letter r
11573163sLatin small letter s
11674164tLatin small letter t
11775165uLatin small letter u
11876166vLatin small letter v
11977167wLatin small letter w
12078170xLatin small letter x
12179171yLatin small letter y
1227A172zLatin small letter z
1237B173{Left curly bracket
1247C174|Vertical line/Vertical bar
1257D175}Right curly bracket
1267E176~Tilde
1277F177DELDelete (DEL)

In the ASCII character set, the Decimal values 0 to 31 as well as Decimal value 127 represent symbols that are non-printable. It is possible to generate these non-printable characters using a key sequence where ^ represents the control key on your keyboard. For example, you could generate a carriage return (Decimal value 13) by pressing the control key followed by the letter M on your keyboard (^M).

All other symbols in the character set can printed or represented on the screen. These printable character values can be seen in the Char field in the table above.

Extended ASCII Characters

DecHexOctCharDescription
12880200  
12981201  
13082202  
13183203  
13284204  
13385205  
13486206  
13587207  
13688210  
13789211  
1388A212  
1398B213  
1408C214  
1418D215  
1428E216  
1438F217  
14490220  
14591221  
14692222  
14793223  
14894224  
14995225  
15096226  
15197227  
15298230  
15399231  
1549A232  
1559B233  
1569C234  
1579D235  
1589E236  
1599F237  
160A0240 No-break space
161A1241¡Inverted exclamation mark
162A2242¢Cent sign
163A3243£Pound sign
164A4244¤Currency sign
165A5245¥Yen/Yuan sign
166A6246¦Broken bar
167A7247§Section sign
168A8250¨Diaeresis
169A9251©Copyright sign
170AA252ªFeminine ordinal indicator
171AB253«Left-pointing double angle quotation mark
172AC254¬Not sign
173AD255­Soft hyphen
174AE256®Registered trademark sign
175AF257¯Macron
176B0260°Degree sign
177B1261±Plus-minus sign
178B2262²Superscript two
179B3263³Superscript three
180B4264´Acute accent
181B5265µMicro sign (mu)
182B6266Pilcrow sign
183B7267·Middle dot
184B8270¸Cedilla
185B9271¹Superscript one
186BA272ºMasculine ordinal indicator
187BB273»Right-pointing double angle quotation mark
188BC274¼Vulgar fraction one quarter
189BD275½Vulgar fraction one half
190BE276¾Vulgar fraction three quarters
191BF277¿Inverted question mark
DecHexOctCharDescription
192C0300ÀLatin capital letter A with grave
193C1301ÁLatin capital letter A with acute
194C2302ÂLatin capital letter A with circumflex
195C3303ÃLatin capital letter A with tilde
196C4304ÄLatin capital letter A with diaeresis
197C5305ÅLatin capital letter A with ring above
198C6306ÆLatin capital letter AE
199C7307ÇLatin capital letter C with cedilla
200C8310ÈLatin capital letter E with grave
201C9311ÉLatin capital letter E with acute
202CA312ÊLatin capital letter E with circumflex
203CB313ËLatin capital letter E with diaeresis
204CC314ÌLatin capital letter I with grave
205CD315ÍLatin capital letter I with acute
206CE316ÎLatin capital letter I with circumflex
207CF317ÏLatin capital letter I with diaeresis
208D0320ÐLatin capital letter ETH
209D1321ÑLatin capital letter N with tilde
210D2322ÒLatin capital letter O with grave
211D3323ÓLatin capital letter O with acute
212D4324ÔLatin capital letter O with circumflex
213D5325ÕLatin capital letter O with tilde
214D6326ÖLatin capital letter O with diaeresis
215D7327×Multiplication sign
216D8330ØLatin capital letter O with stroke
217D9331ÙLatin capital letter U with grave
218DA332ÚLatin capital letter U with acute
219DB333ÛLatin capital letter U with circumflex
220DC334ÜLatin capital letter U with diaeresis
221DD335ÝLatin capital letter Y with acute
222DE336ÞLatin capital letter THORN
223DF337ßLatin small letter sharp s
224E0340àLatin small letter a with grave
225E1341áLatin small letter a with acute
226E2342âLatin small letter a with circumflex
227E3343ãLatin small letter a with tilde
228E4344äLatin small letter a with diaeresis
229E5345åLatin small letter a with ring above
230E6346æLatin small letter ae
231E7347çLatin small letter c with cedilla
232E8350èLatin small letter e with grave
233E9351éLatin small letter e with acute
234EA352êLatin small letter e with circumflex
235EB353ëLatin small letter e with diaeresis
236EC354ìLatin small letter i with grave
237ED355íLatin small letter i with acute
238EE356îLatin small letter i with circumflex
239EF357ïLatin small letter i with diaeresis
240F0360ðLatin small letter eth
241F1361ñLatin small letter n with tilde
242F2362òLatin small letter o with grave
243F3363óLatin small letter o with acute
244F4364ôLatin small letter o with circumflex
245F5365õLatin small letter o with tilde
246F6366öLatin small letter o with diaeresis
247F7367÷Division sign/Obelus
248F8370øLatin small letter o with stroke
249F9371ùLatin small letter u with grave
250FA372úLatin small letter u with acute
251FB373ûLatin small letter u with circumflex
252FC374üLatin small letter u with diaeresis
253FD375ýLatin small letter y with acute
254FE376þLatin small letter thorn
255FF377ÿLatin small letter y with diaeresis

Next Topic : Click Here

This Post Has One Comment

Leave a Reply