Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1

SQRT(x)


Returns the square root of x.
Example:
SELECT SQRT(9)
Result:


3
Example:
SELECT SQRT(-16)
Result:
NULL

STRCMP(string1, string2)


Returns 1 if string1 is the same as string2. If they are different, this function returns 0. A NULL value is
returned if either string is NULL.
Example:
SELECT STRCMP("Sandy", "Sandy")
Results:


1
Example:
SELECT STRCMP("Sandy", "Sandra")
Results:

0
Example:
SELECT STRCMP("Sandy", "sandy")
Results:

0

STD(expression) or STDDEV(expression)


Returns the standard deviation of the given expression. Only non NULL values are used to compute this
value.
Example:
SELECT STD(Quantity) FROM Orders
Results:


2.435

SUM(expression)


Returns the total sum of the given expression. Only non-NULL values are used to compute this value.
Example:
SELECT SUM(Cost) FROM Orders
Results:


10234.34

SUBSTRING_INDEX(x, y, z)


Returns a string from x after z occurrences of y have been found. If y is positive, everything to the left of the
final delimiter is returned. If y is negative, everything to the right is returned.
Example:
SELECT SUBSTRING_INDEX("mysql.3-23-3.Linux.tar.gz", ".", 3")
Result:


'mark@localhost'
Example:
SELECT SUBSTRING_INDEX("mysql.3-23-3.Linux.tar.gz", ".", -3")
Result:

"Linux.tar.gz"
Free download pdf