- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 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查询 再执行ORselect * 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相同的IDelect * from class where (性别not in (男))and (not (年龄between 18 and 21))?not语句的查询 在条件语句前面加上NOT?select top 3 * from ?class order by id 前面最三个数据use liudanselect 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 class group by 年龄 ? ? ?表示对年龄进行汇总,就是说 对相同年龄
您可能关注的文档
- 产后减肥用什么方法最好 节食减肥怎样瘦十斤.doc
- 人力资源管理 ( 第2次 ).doc
- 人力资源 阶段作业1、2.docx
- 交通标志组成结构.docx
- 人行道板技术标准.doc
- 从 if else 到 switch case 再到抽象.docx
- 什么精油收缩毛孔好 达人告诉你什么精油收缩毛孔好.doc
- 从合作原则看课堂师生互动.doc
- 从生活中吸取设计灵感2-1.doc
- 从电影中搜寻最美婚纱灵感.docx
- 2025年大学(康复治疗学)康复评定基础测试试题及答案.doc
- 2025年内蒙古医科大学马克思主义基本原理概论期末考试模拟题必考题.docx
- 2026年四川华新现代职业学院单招职业技能考试模拟试题带答案详解.docx
- 2025年凉山州辅警协警招聘考试真题附答案.docx
- 2025年内蒙古商贸职业学院思想道德修养与法律基础期末考试模拟题必考题.docx
- 2025年冀中职业学院单招(计算机)测试备考题库附答案.docx
- 2025年册亨县辅警招聘考试真题附答案.docx
- 2026年南昌健康职业技术学院单招职业技能考试备考试题带答案详解.docx
- 2025年内蒙古医科大学马克思主义基本原理概论期末考试模拟题必考题.docx
- 2025年兰考三农职业学院思想道德修养与法律基础期末考试模拟题必考题.docx
原创力文档


文档评论(0)