content_image/766479.jpg
<img src='content_image/766479.jpg'>

String-valued functions return NULL  if the length of the result would be greater than the value of the max_allowed_packet  system variable. See Section 5.1.1, “Configuring the Server” . 

For functions that operate on string positions, the first position is numbered 1. 

For functions that take length arguments, noninteger arguments are rounded to the nearest integer. 

• ASCII( str ) 

Returns the numeric value of the leftmost character of the string str . Returns 0  if str  is the empty string. Returns NULL  if str  is NULL . ASCII()  works for 8-bit characters. 

mysql> SELECT ASCII(’2’); -> 50 mysql> SELECT ASCII(2); -> 50 mysql> SELECT ASCII(’dx’); -> 100 

See also the ORD()  function. 

• BIN( N ) 

Returns a string representation of the binary value of N , where N  is a longlong ( BIGINT ) number. This is equivalent to CONV( N ,10,2) . Returns NULL  if N  is NULL . 

mysql> SELECT BIN(12); -> ’1100’ 

• BIT_LENGTH( str ) 

Returns the length of the string str  in bits. 

mysql> SELECT BIT_LENGTH(’text’); -> 32 

• CHAR( N ,... [USING charset_name ]) 

CHAR()  interprets each argument N  as an integer and returns a string consisting of the characters given by the code values of those integers. NULL  values are skipped. 

mysql> SELECT CHAR(77,121,83,81,’76’); -> ’MySQL’ mysql> SELECT CHAR(77,77.3,’77.3’); -> ’MMM’ 

CHAR()  arguments larger than 255 are converted into multiple result bytes. For example, CHAR(256)  is equivalent to CHAR(1,0) , and CHAR(256*256)  is equivalent to CHAR(1,0,0) : 

mysql> SELECT HEX(CHAR(1,0)), HEX(CHAR(256)); +----------------+----------------+ | HEX(CHAR(1,0)) | HEX(CHAR(256)) | 

