zoukankan      html  css  js  c++  java
  • 《mysql必知必会》学习_第11章

    第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()返回正切值

     

  • 相关阅读:
    ADO.NET API+MVC实现文件上传及文件下载
    ASP.NET MVC+ajax实现文件上传及文件下载
    js实现cookie读写的简单操作
    数据库 DML、DDL、DCL的简单介绍
    winfrom 控件Chrat 代码实现
    C# Redis简单存储string
    MVC AJAX方法 文件上传下载
    MVC 文件上传下载
    js设置cookie(简单保存cookie)
    cookie的执行过程
  • 原文地址:https://www.cnblogs.com/qiyuanjiejie/p/9406349.html
Copyright © 2011-2022 走看看