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

(singke) #1

ENCRYPT(word[, seed])


Returns an encrypted string. Uses the UNIX crypt() function. The optional seed can be a 2-letter string.
Example:
SELECT ENCRYPT('tacobell', 'sa')
Result:


saAUT2FASzS2s

EXP(x)


Returns the value of the base of natural logarithms, raised to the power of x.
Example:
SELECT EXP(5)
Result:


148.413159

EXTRACT(value FROM date)


Returns the in one of the following formats:


Accepted values:
SECOND
MINUTE
HOUR
DAY
MONTH
YEAR
MINUTE_SECOND
HOUR_MINUTE
DAY_HOUR
YEAR_MONTH
HOUR_SECOND
DAY_MINUTE
DAY_SECOND
See ADDDATE(), and DATE_SUB().
Example:
SELECT EXTRACT(DAY FROM "2000-01-27"
Result:

1
Example:
SELECT EXTRACT(DAY_SECOND FROM "2000-01-27 12:01:45"
Result:

10145—returned in DAY/HOUR/MINUTE

FIELD(x, y, z, ...)


Returns the position in the argument list where x and the string match. See ELT().
Example:
SELECT FIELD("Mark", "Sam", "Ken", "Mark", "Scott")
Result:


3

FIND_IN_SET(x, stringlist)


Returns the position in the string list where x is found. If x is not in the string list, 0 is returned. The string list
is a list of string values separated by a comma.
Example:
SELECT FIND_IN_SET("Mark", "Mark, Stan, Ken")
Result:


1
Free download pdf