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

(singke) #1
"March"

NOW()


Returns the current date and time. See CURTIME(), CURRENT_TIMESTAMP, and SYSDATE().
Example:
SELECT NOW()
Result:


'2000-01-30 23:51:00'

OCT(x)


Returns an octal value of x, where x is a BIGINT. The return value type is a string.
Example:
SELECT OCT(10)
Result:


12

OCTET_LENGTH()


See LENGTH().


PASSWORD(password)


Returns an encrypted string of the given password string.
Example:
SELECT PASSWORD('tacobell')
Result:
35decd2c4ab0f0c1


PERIOD_ADD(x, y)


Returns a value resulting in the sum of y months added to period x. x is not in date value.
Example:
SELECT PERIOD_ADD(9910, 4)
Result:


200002

PERIOD_DIFF(X, Y)


Returns the number of months between x and y. x and y should be in either YYMM or CCYYMM format.
Example:
SELECT PERIOD_DIFF(200010, 199804)
Result:


30

PI()


Returns the value of PI.
Example:
SELECT PI()
Result:


3.141593

POSITION(x, y)


Returns the position of the first occurrence of x in y. Returns 0 if x is not found in y.
Example:
SELECT LOCATE("fox", "The quick brown fox jumped")
Result:


17
Example:
SELECT POSITION("ox", "The quick brown fox")
Result:

18
Free download pdf