常用SQL语句格积式累.docxVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
常用SQL语句格积式累

常用SQL语句格式积累 ? ?一、常用的语句格式积累: ? Select top 3 * from class order by id desc 表示查询前3条的数据并且按降来排 ? select distinct 年龄 from class ?去除重复行的查询 select top 2 * from class order by newid() 表示随便查询2行数据 select * from class where 年龄=20 or 年龄=19 and 性别=男 表示先查询年龄等于19 并且是男的 在查询所有年龄等于20的人 ?先执行AND查询 再执行OR select * from class where id not in (select id from class1) 表示查询表一中在表2中没有的数据 select * from class where id between 1 and 5 表示查询1到5的数据 select * from class where id not between 1 and 5 表示查询不是1到5的数据 select * from class where 姓名like 刘% 表示查询刘开头的人 select * from class where 姓名like %丹%查询包含丹的人 select * from class where 姓名like [刘丹]%查询以刘或者以丹开头的数据 select * from class where 姓名like [%刘丹]%查询包含丹或者刘的数据 select * from class where 年龄like [^1-2]%查询数据不是以1到2之间开头的 select * from class where 年龄like [^刘陈]% 查询不是以刘或者陈开头的数据 select * from class where 工作地址is null 表示查询工作地址不是空值的数据 select * from class where 工作地址is not null 查询不是空植的数据 select * from class where id all(select id from class1)表示查询表2在表一中没有的ID数据 select * from class where id = any(select id from class1) 查询表一中和表2相同的ID elect * from class where (性别not in (男))and (not (年龄between 18 and 21))? not语句的查询 在条件语句前面加上NOT? select top 3 * from ?class order by id 前面最三个数据 use liudan select top 3 * from ?class order by id desc 最后三个的数据 select ltrim(rtrim(姓名)) from class 里面函数RTRIM代表删除结尾空格数据 外面函数 ltrim 删除前面空格的数据 select 姓名+, as 姓名,lower(gege) as gege from class ? ?给姓名的每条数据加上 ,; 把gege 列转换为小写 select 姓名+, as 姓名,upper(gege) as gege from class 后面函数把数据全部转换为大写 select * from class where month(日期)=9 and year(日期)=1993 and day(日期)=9 分别是三个函数 第一个是对指定的日期 月 ,年,日 select 年龄-id as a from class 表示用每一行的数据用年龄-id得到的数据+ - * / 都可以用 select sum(年龄) as a from class ?求和 select * from class where 年龄(select avg(年龄) from class) ?求年龄大于平均值的数据 select * from class where 年龄= (select max(年龄) from class) 求年龄最大的、 select * from class where 年龄= (select min(年龄) from class) 年龄最小的人 select count(*) from class 表中数据总条数 select count(年龄) from class 查询年龄不为空的 select sum(年龄) from class where 性别=男 得到性别为男的的总年龄数 select 年龄,count(*) from cl

文档评论(0)

cunzhu74 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档