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

(singke) #1

FLOOR(x)


Returns the largest integer value that is not greater than x. The returned value is converted to a BIGINT.
See CEILING().
Example:
SELECT FLOOR(4.56)
Result:


4
Example:
SELECT FLOOR(-4.56)
Result:

-5

FORMAT(NUM, DEC)


Returns the number given in NUM formatted to 'x,xxx,xxx.x' rounded to the decimals given in DEC. If
DEC is 0 , no decimal part will be returned.
Example:
SELECT FORMAT(12345.45, 1)
Result:


12,345.5

FROM_DAYS(days)


Given a day number (from TO_DAYS()), will return a date.
Example:
SELECT FROM_DAYS(694734)
Result:


1902-02-13

FROM_UNIXTIME(unix_time[, format_symbols])


Returns a date based on the given unix_time. The optional parameter provides formatting.
Example:
SELECT FROM_UNIXTIME(951631200, '%M %D %Y')
Result:


February 27 2000

GREATEST(x, y, ...)


Returns the largest valued argument. Uses the same rules as LEAST for comparisons. See LEAST().
Example:
SELECT GREATEST(45, 222, 3, 99)
Result:


222
Example:
SELECT GREATEST("A", "B", "C")
Result:

C
Example:
SELECT GREATEST("Mark", "Sam", "Ken")
Result:

Sam

HEX(x)


Returns a hexadecimal value of x, where x is a BIGINT. The return value type is a string.
Example:
SELECT HEX(15)
Result:

Free download pdf