第11章:使用数据处理函数。

P69 文本处理函数,upper()函数把文本变成大写字体。

select vend_name,upper(vend_name) as vend_name_upcase from vendors order by vend_name; #upper()把vend_name列的文本变成了大写,并且重新命名为vend_name_upcase #

其他的常用的函数:

length()返回串的长度

lower() 将文本变成小写字体。

其他的,left()返回串左边的字符,locate()找到串的一个子串。 LTrim()去掉串左边的空格,Right()返回串右边的字符。substring()返回子串的字符。试了一下,不知道怎么用,或是不知道用不用有什么区别。

select cust_name,cust_contact from customers where cust_contact ='Y.Lie';  #查找列cust_contact里面名Y.Lie,但是没有没有这个顾客名,所以返回的值是空的#

select cust_name,cust_contact from customers where soundex(cust_contact)=soundex('Y.Lie); #soundex()函数搜索发音类似的,类似模糊搜索,注意条件的里边都要用soundex()函数。#

P71 日期和时间处理函数。注意:为了排除多义性混乱的各种可能性,日期的首选首选格式:yyyy-mm-dd。

select cust_id,order_num from orders where order_date='2005-09-01';  #检索订单日期是2005-09-01 #

select cust_id,order_num from orders where date(order_date)='2005-09-01';  #倘若订单日期的格式是yyyy-mm-dd xx:xx:xx  ,那where order_date='2005-09-01'就会检索失败,为了保险起见,用date()函数,提取日期的部分信息,相应地,如果想要时间的时间时部分(即是xx:xx:xx部分),用time()函数,如:where time(order_date)=13:08:22 #

P73 检索一段时间内的信息。

select cust_id,order_num from orders where date(order_date) between '2005-09-01' and '2005-09-30'; #检索的时间范围是20050901到20050930#

select cust_id,order_num from orders where year(order_date)=2005 and month(order_date)=9 ; #检索的年份是2005,月份是9月,要同时满足这两个条件。#注意:上面检索的是时间格式,所以要用引号,下面检索的年份和月份已经相当于一个数值,不需要引号(自己的理解)#

其他的数值处理函数有:

abs() 绝对值;

cos()一个角度的余弦

exp()一个值的指数值

mod()返回除操作的余数  #不懂它的操作#

pi()返回圆周率

rand()返回一个随机值

sin()返回一个角度的正弦

sqrt()返回一个数的平方根

tan()返回正切值

最新文章

  1. 00 EPLAN安装问题
  2. 网友转发的很全的 LISTCTL 控件使用的说明
  3. SpringMyBatis解析1-使用示例
  4. Spark运行原理解析
  5. 源代码tfs to git
  6. Android点击View显示PopupWindow,再次重复点击View关闭PopupWindow
  7. (六)C#中判断空字符串的三种方法性能分析
  8. EasyUI_Datagrid学习总结
  9. Linux性能监控的几个工具(转)
  10. hibernate符合主键
  11. 正确设置网站title、keywords、description(转载)
  12. hdu 5392 Infoplane in Tina Town(数学)
  13. Andorid开发中如何去除标题栏title
  14. A 洛谷 P3601 签到题 [欧拉函数 质因子分解]
  15. python_ 函数
  16. LeetCode算法题-Word Pattern(Java实现)
  17. spring boot下MultipartHttpServletRequest如何提高上传文件大小的默认值
  18. Alpha答辩总结
  19. 关于查询排序DTO的封装
  20. MYSQL-max_binlog_cache_size参数

热门文章

  1. nginx 启动报错 “/var/run/nginx/nginx.pid" failed” 解决方法
  2. HDU_1548
  3. Introduction to 3D Game Programming with DirectX 11 翻译--开篇
  4. 关于RNA-Seq数据去接头(Adapter)这事需要讲一讲
  5. APP强制退出
  6. django POST表单的使用
  7. 如何在 Laravel 中连接多个 MySQL 数据库
  8. [转载]How To Install Nginx And PHP-FPM On CentOS 6 Via Yum
  9. jvm层面锁优化+一般锁的优化策略
  10. (转)用webbrowser做的网站登陆程序,如何获取cookie并且保存在程序中 (IE8有效) ,用途嘛,你懂的。