函数名称 | 描述 | 示例 |
[ /doc/refman/5.0/en/control-flow-functions.html#function_if]IF[/url] | If/else 结构 | IF(a=b, 'equals', 'differs') |
[ /doc/refman/5.0/en/string-functions.html#function_elt]ELT[/url] | 返回索引的字符串 | ELT(index, 'string1', 'string2', 'string3') |
[ /doc/refman/5.0/en/string-functions.html#function_coalesce]COALESCE[/url] | 返回第一个非空参数
| COALESCE(field1, field2, 'Undefined') |
[ /doc/refman/5.0/en/comparison-operators.html#operator_is-null]ISNULL[/url] | | ISNULL(field1) |
[ /doc/refman/5.0/en/string-functions.html#function_concat]CONCAT[/url] | 返回连接后的字符串
| CONCAT(firstname, ' ', lastname) |
[ /doc/refman/5.0/en/string-functions.html#function_substr]SUBSTR[/url] | 返回指定的子字符串 | SUBSTR('abcdef', 2, 3) |
[ /doc/refman/5.0/en/string-functions.html#function_trim]TRIM[/url] | 删除开头和结尾的空格 | TRIM(' blah ') |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_date]DATE[/url] | 提取日期或日期时间表达式的日期部分
| DATE() |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_date-format]DATE_FORMAT[/url] | 指定格式日期
| DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y') |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_current-date]CURRENT_DATE[/url] | 返回当前日期 | CURRENT_DATE() |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_now]NOW[/url] | 返回当前日期和时间 | NOW() |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_time]TIME[/url] | 提取表达式的时间部分
| TIME() |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_to-days]TO_DAYS[/url] | 返回日期参数转换后的天数
| TO_DAYS('2009-05-01') |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_from-days]FROM_DAYS[/url] | 转换一个日期数为日期
| FROM_DAYS(12345) |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_year]YEAR[/url] | 返回日期的年
| YEAR(DATE()) |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_month]MONTH[/url] | 返回日期的月
| MONTH(DATE()) |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_day]DAY[/url] | 返回日期的日 (0-31)
| DAY(DATE()) |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_date-add]DATE_ADD[/url] | 添加时间值(间隔)到日期。参见下面允许的间隔单位
| DATE_ADD(NOW(), INTERVAL 1 HOUR) |
[ /doc/refman/5.0/en/date-and-time-functions.html#function_date-sub]DATE_SUB[/url] | 缩短时间值(间隔)到日期。参见下面允许的间隔单位
| DATE_SUB(NOW(), INTERVAL 5 MINUTE) |
[ /doc/refman/5.0/en/mathematical-functions.html#function_%20round]ROUND[/url] | 返回参数X的四舍五入的数值。 | ROUND(12.356, 2) |
[ /doc/refman/5.0/en/mathematical-functions.html#function_floor]FLOOR[/url] | 返回不大于参数的最大整数值
| FLOOR(12.356) |
[ /doc/refman/5.0/en/miscellaneous-functions.html#function_inet-aton]INET_ATON[/url] | 返回IP地址的数值
| INET_ATON('15.15.121.12') |
[ /doc/refman/5.0/en/miscellaneous-functions.html#function_inet-ntoa]INET_NTOA[/url] | 返回数值的IP地址
| INET_NTOA(1231654) |