MySQL使用--組み込み関数編
2946 ワード
一.文字列クラス:
二.数学:
三.日付時間クラス:
添付:INTERVALで使用可能なタイプ
公式リンク:
CHARSET(str) //
CONCAT (string2 [,... ]) //
INSTR (string ,substring ) // substring string , 0
LCASE (string2 ) //
LEFT (string2 ,length ) // string2 length
LENGTH (string ) //string
LOAD_FILE (file_name ) //
LOCATE (substring , string [,start_position ] ) INSTR,
LPAD (string2 ,length ,pad ) // pad string , length
LTRIM (string2 ) //
REPEAT (string2 ,count ) // count
REPLACE (str ,search_str ,replace_str ) // str replace_str search_str
RPAD (string2 ,length ,pad) // str pad , length
RTRIM (string2 ) //
STRCMP (string1 ,string2 ) // ,
SUBSTRING (str , position [,length ]) // str position , length ,
:mysql , 1 , position 1
TRIM([[BOTH|LEADING|TRAILING] [padding] FROM]string2) //
UCASE (string2 ) //
RIGHT(string2,length) // string2 length
SPACE(count) // count
二.数学:
ABS (number2 ) //
BIN (decimal_number ) //
CEILING (number2 ) //
CONV(number2,from_base,to_base) //
FLOOR (number2 ) //
FORMAT (number,decimal_places ) //
HEX (DecimalNumber ) //
:HEX() , ASC-11 , HEX(’DEF’) 4142143
, , HEX(25) 19
LEAST (number , number2 [,..]) //
MOD (numerator ,denominator ) //
POWER (number ,power ) //
RAND([seed]) //
ROUND (number [,decimals ]) // ,decimals ]
:
SIGN (number2 ) // , 0
SQRT(number2) //
三.日付時間クラス:
ADDTIME (date2 ,time_interval ) // time_interval date2
CONVERT_TZ (datetime2 ,fromTZ ,toTZ ) //
CURRENT_DATE ( ) //
CURRENT_TIME ( ) //
CURRENT_TIMESTAMP ( ) //
DATE (datetime ) // datetime
DATE_ADD (date2 , INTERVAL d_value d_type ) // date2
DATE_FORMAT (datetime ,FormatCodes ) // formatcodes datetime
DATE_SUB (date2 , INTERVAL d_value d_type ) // date2
DATEDIFF (date1 ,date2 ) //
DAY (date ) //
DAYNAME (date ) //
DAYOFWEEK (date ) // (1-7) ,1
DAYOFYEAR (date ) //
EXTRACT (interval_name FROM date ) // date
MAKEDATE (year ,day ) // ,
MAKETIME (hour ,minute ,second ) //
MONTHNAME (date ) //
NOW ( ) //
SEC_TO_TIME (seconds ) //
STR_TO_DATE (string ,format ) // , format
TIMEDIFF (datetime1 ,datetime2 ) //
TIME_TO_SEC (time ) // ]
WEEK (date_time [,start_of_week ]) //
YEAR (datetime ) //
DAYOFMONTH(datetime) //
HOUR(datetime) //
LAST_DAY(date) //date
MICROSECOND(datetime) //
MONTH(datetime) //
MINUTE(datetime) //
添付:INTERVALで使用可能なタイプ
DAY ,DAY_HOUR ,DAY_MINUTE ,DAY_SECOND ,HOUR ,HOUR_MINUTE ,HOUR_SECOND ,MINUTE ,MINUTE_SECOND,MONTH ,SECOND ,YEAR
公式リンク:
http://dev.mysql.com/doc/refman/5.1/zh/stored-procedures.html