Friday, September 10th, 2010

MySQL String Functions

BINARY
string1=BINARY(string2)
Returns the binary representation of a string. This function can be used to force case-sensitive comparisons when they would otherwise not occur.

BIT_LENGTH
bits=BIT_LENGTH(string)
Returns the number of bits in a string.

CHAR_LENGTH
length=CHAR_LENGTH(string)
Returns the number of characters in a string. Like LENGTH, except that it returns the number of characters, rather than the number of bytes, for multibyte character sets.

CHARACTER_LENGTH
length=CHARACTER_LENGTH(string)
Alias for CHAR_LENGTH.

COMPRESS
string1=COMPRESS(string2)
Returns a compressed version of a string.

DECODE
string1=DECODE(string2,password)
Decrypts a string that has been encrypted with ENCRYPT .

ELT
string1=ELT(number,string2[,...])
Returns one of the elements in a list.

ENCODE
string1=ENCODE(string2,password)
Encrypts a string. The string can be decrypted with DECODE.

ENCRYPT
string1=ENCRYPT(string2,seed)
Encrypts a string. The string cannot be decrypted with DECODE.

EXPORT_SET
string=ENCODE_SET(number,on_string, off_string,seperator,no_of_bits)
Returns the binary representation of a number encoded with strings for on and off bits.

FIELD
number=FIELD(string1,string2[,...])
Searches for a string in a list of strings.

INET_ATON
number=INET_ATON(IPAddress)
Converts an IP address into a numeric representation.

INET_NTOA
IPAddress=INET_NTOA(number)
Converts a number into a corresponding IP address.

LOWER
string1=LOWER(string2)
Synonym for LCASE.

MID
string1=MID(string2,start [,length])
Returns a substring. Similar to SUBSTR.

OCTET_LENGTH
length=OCTET_LENGTH(string)
Alias for LENGTH.

ORD
position=ORD(string)
Returns the ordinal value of the character in the ASCII character set.

PASSWORD
string1=PASSWORD(string2)
Encrypts the given string as a MySQL password.

POSITION
position=POSITION(substring IN string)
Returns the position of the substring in the string. Similar to LOCATE.

QUOTE
string1=QUOTE(string2)
Returns a string with special characters preceded by an escape character.

REVERSE
string1=REVERSE(string2)
Reverses the order of characters in a string.

RIGHT
string1=RIGHT(string2,length)
Returns the rightmost portion of a string.

SHA
string1=SHA(string2)
Returns a 160-bit Secure Hash Algorithm (SHA) checksum for the string.

SHA1
string1=SHA1(string2)
Alias for SHA.

SOUNDEX
string1=SOUNDEX(string2)
Returns the SOUNDEX for a string. In theory, two strings that “sound alike” will have similar SOUNDEX values.

SPACE
spaces=SPACE(count)
Returns the specified number of space characters.

SUBSTRING_INDEX
string1=SUBSTRING_INDEX(string2, delimiter,count)
Returns a string from a character-delimited set of strings.

UNCOMPRESSED_LENGTH
length=UNCOMPRESSED_LENGTH( compressed_string)
Returns the length of a compressed string as if it were decompressed.

UNCOMPRESS
string1=UNCOMPRESS(string2)
Reverses the effect of COMPRESS.

UNHEX
character=UNHEX(HexNumber)
Converts a hexadecimal number to its ASCII equivalent.

UPPER
string1=UPPER(string2)
Converts a string to uppercase. Synonym for UCASE.

Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

Tags: ,

Readers Comments (0)




Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


Latest Additions

Popular User Submitted Links

1


Hosted & Optimized JS Libraries – Cached Commons

1


Multi-File Uploader & Resizer – Agile Uploader

1


Open source online notebook-to-do-list manager

1


3 tier app design in silverlight using azure & RIA services

1


Polymaps – A JS Library For Image & Vector-Tiled Maps

eXTReMe Tracker