SQL查询指导.ppt

  1. 1、本文档共18页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
SQL查询指导

SQL查询指导 基本语法 Select 内容列表 From 表列表 Where 查询条件表达式 Order By 排序关键字列表 Group By 分组关键字 带表达式的查询 Select sno,cno,grade-60 from sc where grade=60 Student(sno,sname,sbirth) Select * from student Select sno,sname,year(date())-year(sbirth) as age from student 选择查询WHERE 比较大小:(NOT) 比较运算符 Select * from student where sage20 Select * from student where not sage20 = ,= ,= 多重条件查询:AND / OR Select * from student where sage25 or sage20 Select * from student where sage20 and sage25 确定范围:(NOT) BETWEEN AND Select * from student where sage=20 and sage=25 Select * from student where not sage between 20 and 25 消除重复的行:DISTINCT / ALL Select DISTINCT cno,cname from course,sc where sc.cno=course.cno 确定集合:(NOT) IN Select * from student where sno=‘01’ or sno=‘02’ or sno=‘03’ Select * from student where sno not in (‘01’,’02’,’03’) 字符匹配(模糊查询):(NOT) LIKE Select * from student where sname like ‘张%’ ‘_’:任意一个字符 ‘%’:任意字符串 Select * from student where sno like ‘____01%’ Select * from student where sname like ‘%三%’ 涉及空值的查询:IS (NOT) NULL Select * from student where sname is NULL Select * from student where len(sname)=0 连表查询 等值连接 Select student.sno,sname,course.cno,cname,grade from student,course,sc where student.sno=sc.sno and course.cno=sc.cno 复合条件连接 自身连接 Select sa.* from student sa,student sb where sa.sage=sb.sage and sa.sname=‘张三’ 子查询块嵌套查询 带有IN谓词的子查询 Select student.sno,sname from student,sc where student.sno=sc.sno and cno=‘00001’ Select sno,sname from student where sno in (select sno from sc where cno=‘00001’) 带有比较运算符的子查询 Select * from student where sage=(select sage from student where sname=‘张三’) 带有ANY或ALL谓词的子查询 Select * from student where sage=(select max(sage) from student) Select * from student where sage=ALL(select sage from student) Select * from student where sage=any(select sage from student) 带有EXISTS谓词的子查询 查询选修所有课程的学生名单 Select sno,sname from student where not exists (select * from course where not exists(select * from sc where student.sno=sc.sno and course.cno=sc.cno)) Select sno from

文档评论(0)

asd522513656 + 关注
实名认证
内容提供者

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

1亿VIP精品文档

相关文档