zoukankan      html  css  js  c++  java
  • SQL学习分享之数据链接(二)

    1、插入数据

    insert into table(id,name) values("","")                                                            ---插入数据到table表中

    如:INSERT INTO sms.Communication  ( RefType,RefId,Type,Message,CreateUserId,CreateDate ) values (1,118113,11,'This is a test!affiliate to sms',1009,GETDATE())

    2、查询在某一时间段的数据

    a. time between '2014/04/18' and '2014/06/19'                                               ----查询时间段在4月份与6月份的数据

    如:select count(*) from client.RequestByRecurrence where RequestProstatusId=3 and ScheduleTime between '2014/6/1'and '2014/6/19'

    b.time >'2014/04/18' and time< '2014/06/19'                                                 ----得出的结果与上面的一致

    Tip:注意likes '2014/05%'                                                                               ----like关键字用于字符串的匹配

    3、多表链接

    select count(*)  from(
     select RequestNum,RequestProstatusId,sms.ServiceCode.ServiceCodeId,sms.ServiceCategory.ServiceCategoryName,ScheduleTime
      as a from client.RequestByRecurrence inner join sms.ServiceCode on client.RequestByRecurrence.ServiceCodeId=sms.ServiceCode.ServiceCodeId
      inner join sms.ServiceType on sms.ServiceType.ServiceTypeId=sms.ServiceCode.ServiceTypeId
      inner join sms.ServiceCategory on sms.ServiceType.ServiceCategoryId=sms.ServiceCategory.ServiceCategoryId                                                                 --------这个多表链接做查询
      )
     as schedule where RequestProstatusId=3 and ServiceCategoryName='Landscaping'                                                                                                            -------在上面做出的查询中统计满足Where条件的数目

  • 相关阅读:
    Python网络爬虫四大选择器(正则表达式、BS4、Xpath、CSS)总结
    如何利用CSS选择器抓取京东网商品信息
    如何利用Xpath抓取京东网商品信息
    如何利用BeautifulSoup选择器抓取京东网商品信息
    利用Python正则表达式抓取京东网商品信息
    jacoco查看覆盖率
    Centos7.X 搭建Grafana+Jmeter+Influxdb 性能实时监控平台(不使用docker)
    记录工作中遇到的BUG,经典的数据库时区问题和字段类型tinyint(1)问题
    jmeter分布式压测
    Linux性能优化思路
  • 原文地址:https://www.cnblogs.com/tyen0921/p/3797249.html
Copyright © 2011-2022 走看看