码迷,mamicode.com
首页 > 数据库 > 详细

sql 基础--mysql 5 (4)

时间:2015-02-12 15:32:29      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

9.数据处理函数

  文本处理:Upper 大写

mysql> select uid,name,msg, Upper(name) as UpperName from pw_luck;
+-----+-----------+------+-----------+
| uid | name      | msg  | UpperName |
+-----+-----------+------+-----------+
|   0 | Wilson    |  100 | WILSON    |
|   1 | zhangsan  |  100 | ZHANGSAN  |
|   2 | lisi      | 1001 | LISI      |
|   3 | wang5     | 1001 | WANG5     |
|   7 | zhangsan7 | 1000 | ZHANGSAN7 |
|   8 | zhangsan8 | 1000 | ZHANGSAN8 |
|   9 | zhangsan9 | 1000 | ZHANGSAN9 |
|  10 | wang5     | 1000 | WANG5     |
|  11 | wang5%    | 2000 | WANG5%    |
|  12 | WANG5     | 1000 | WANG5     |
+-----+-----------+------+-----------+
10 rows in set (0.02 sec)

  文本处理:Soundex匹配所有发音类似的项

mysql> select uid,name,msg, Upper(name) from pw_luck where Soundex(name)=Soundex(wangwu);
+-----+--------+------+-------------+
| uid | name   | msg  | Upper(name) |
+-----+--------+------+-------------+
|   3 | wang5  | 1001 | WANG5       |
|  10 | wang5  | 1000 | WANG5       |
|  11 | wang5% | 2000 | WANG5%      |
|  12 | WANG5  | 1000 | WANG5       |
+-----+--------+------+-------------+
4 rows in set (0.03 sec)

  日期和时间处理函数

    Data() 2012-12-12

    Year()  2012

    Mounth() 2

  数值处理: Abs绝对值 Cos余弦 Exp指数 Mod余数 Sqrt平方根

mysql> select name,msg,Sqrt(msg) from pw_luck;
+-----------+------+--------------------+
| name      | msg  | Sqrt(msg)          |
+-----------+------+--------------------+
| Wilson    |  100 |                 10 |
| zhangsan  |  100 |                 10 |
| lisi      | 1001 |  31.63858403911275 |
| wang5     | 1001 |  31.63858403911275 |
| zhangsan7 | 1000 | 31.622776601683793 |
| zhangsan8 | 1000 | 31.622776601683793 |
| zhangsan9 | 1000 | 31.622776601683793 |
| wang5     | 1000 | 31.622776601683793 |
| wang5%    | 2000 | 44.721359549995796 |
| WANG5     | 1000 | 31.622776601683793 |
+-----------+------+--------------------+
10 rows in set (0.02 sec)

  

sql 基础--mysql 5 (4)

标签:

原文地址:http://www.cnblogs.com/wjw334/p/4288080.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!