Mysql String Functions: Prof. Ryan Celis
Mysql String Functions: Prof. Ryan Celis
Syntax:
SELECT ASCII(FIELDNAME) from TABLENAME
BIN()
Returns a string representation of the binary
value
Syntax:
SELECT BIN(FIELDNAME) from TABLENAME
BIT_LENGTH
Returns the length of the string in bits.
Syntax:
SELECT BIT_LENGTH(FIELDNAME) from
TABLENAME
CHAR()
Return the character of the given ascii code
Syntax:
SELECT CHAR(77, 121, 83, 81, 76)
CHAR_LENGTH
Returns the length of the string, measured in
characters
Syntax:
SELECT CHAR_LENGTH(FIELDNAME) from
TABLENAME
CONCAT()
Return concatenated values
Syntax:
SELECT CONCAT(FIELD1, FIELD2) from
TABLENAME
FORMAT()
Formats the number to a decimal place
Syntax:
SELECT FORMAT(FIELDNAME, num) from
TABLENAME
HEX()
Returns a hexadecimal string representation
Syntax:
SELECT HEX(FIELDNAME) from TABLENAME
INSERT()
Returns the string value, with the substring
beginning at position pos and len characters
long replaced by the string newstr.
Syntax:
SELECT INSERT(FIELDNAME, pos, len, newstr)
from TABLENAME
INSTR()
Returns the position of the first occurrence of
substring substr.
Syntax:
SELECT INSTR(str, FIELDNAME) from
TABLENAME
LCASE()
Returns the values in lower case
Syntax:
SELECT LCASE(FIELDNAME) from TABLENAME
LEFT()
Returns the leftmost characters from the
string
Syntax:
SELECT LEFT(FIELDNAME, num) from
TABLENAME
LTRIM()
Returns the string with left space characters
removed.
Syntax:
SELECT LTRIM(FIELDNAME) from TABLENAME
OCT()
Returns a string representation of the octal
value
Syntax:
SELECT OCT(FIELDNAME) from TABLENAME
REPEAT()
Returns a string repeated count times
Syntax:
SELECT REPEAT(FIELDNAME, count) from
TABLENAME
REPLACE()
Returns the string with all occurrences of the
string from_str replaced by the string to_str
Syntax:
SELECT REPLACE(FIELDNAME, from_str, to_str)
from TABLENAME
REVERSE()
Returns the string with the order of the
characters reversed.
Syntax:
SELECT REVERSE(FIELDNAME) from
TABLENAME
RIGHT()
Returns the rightmost characters from the
string
Syntax:
SELECT RIGHT(FIELDNAME, num) from
TABLENAME
RTRIM()
Returns the string with trailing space
characters removed
Syntax:
SELECT RTRIM(FIELDNAME) from TABLENAME
UCASE()
Returns the values in upper cases
Syntax:
SELECT UCASE(FIELDNAME) from TABLENAME
ACTIVITY
Table: PLAYERS