2oracle数据库4高级查询sql.pdfVIP

  1. 1、本文档共13页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  5. 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  6. 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  7. 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  8. 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
子 在一个sql 中嵌套另一个sql 语句称为子 子 的 结果返回单行时 可以使用 子 中返回多行时 不能在使用 = 而应该使用in In any 子 中的最低值 all 最高值 exists 是否满足 Rownum 伪列 在每一次 过程中动态省成 如果有排序,先对结果集进行排序,再把排序 结果集当作虚拟表,然后再对这个虚拟表 取值 Rownum 是伪劣 动态生成的, 不需要表的前缀 在 应用的场景 1 from 2where 分页返回数据 分页的优点: /** --分页显示商品 id、商品名称、上架时间、每页显示4 条 --请编写 第二页商品 的sql 语句 select id as 商品编号, name as 商品名称, saledate as 上架时间 from es_product where rownum 4 and rownum=8 --将rownum 固化 select id as 商品编号, name as 商品名称, saledate as 上架时间 ,rownum rn from es_product --通过限制rn 的范围取 select id as 商品编号, name as 商品名称, saledate as 上架时间 from (select id, name, saledate,rownum rn from es_product) where rn4 and rn=8 --建议 将固化后的结果集取个别名 select id as 商品编号, name as 商品名称, saledate as 上架时间 from (select id, name, saledate,rownum rn from es_product) a where a.rn4 and a.rn=8 **/ 练习: /** --分页显示商品id 、商品名称、上架时间,每页显示4 条 -- 第三页商品 select id ,name ,saledate from (select id ,name ,saledate, rownum rn from es_product) where rn8 and rn=12 --按上架时间分页显示商品id 、商品名称、上架时间,每页显示4 条 -- 第三页商品 select id ,name, saledate from (select id , name , saledate , rownum rn from es_product) where rn8 and rn =12 **/ 表连接 /** -- 所有用户的用户姓名、 、订单号、订购日期以及订单状态、商品所属 名称 SELECT es_product. id , name, price, sortname FROM es_product , es_sort WHERE es_product.sort_id=es_sort.id AND es_sort.sortname = 图书 --改进 SELECT a.id , a.name , a.price, b. sortname FROM es_product a , es_sort b WHERE a.sort_id =b.id AND b.sortname = 图书 **/ 什么时候用子 ?什么使用使用表 呢? 表连接 语法 Select 要 的字段 from 表 1, 表2 where 连接条件 Oracle 中的表连接 分为 内链接 外连接 自连接 内链接中的非等值连接 /** -- 所有单价介于20-35 元之间的商品名称,价格,库存量以及商品类别名称 select name , price , stockcount,sortname from es_product a, es_sort b where a.sort_id=b.id and a.price=20 and a.price=35 **/ /** -- 所有单价大于500 的商品的商品名称,价格,库存量以及商品类别名称 select name , price , stockcount ,sortname from es_product

文档评论(0)

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

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

1亿VIP精品文档

相关文档