MySQL----with as用法

示例:

with C as (select * from class)

select *from C 

第一个语句是将(select * from calss)的查询结果记录为C,后续可以将C看做一个实际存在的表查询。

with子句的返回结果存到用户的临时表空间中,只做一次查询,反复使用,提高效率

 WITH AS短语,也叫做子查询部分(subquery factoring),是用来定义一个SQL片断,该SQL片断会被整个SQL语句所用到。这个语句算是公用表表达式(CTE)。

也就是将重复用到的大批量 的SQL语句,放到with  as 短语中,加个别名,在后面需要时可直接用。对大批量SQL数据,可起到优化作用。

二、with的相关总结(摘录)
1.使用with子句可以让子查询重用相同的with查询块,通过select调用(with子句只能被select查询块引用),一般在with查询用到多次情况下。在引用的select语句之前定义,同级只能定义with关键字只能使用一次,多个用逗号分割。
2.最后一个with 子句与下面的查询之间不能有逗号,只通过右括号分割,with 子句的查询必须用括号括起来
3.如果定义了with子句,而在查询中不使用,那么会报ora-32035 错误:未引用在with子句中定义的查询名。(至少一个with查询的name未被引用,解决方法是移除未被引用的with查询),注意:只要后面有引用的就可以,不一定非要在主查询中引用,比如后面的with查询也引用了,也是可以的。
4.前面with子句定义的查询在后面的with子句中可以使用。但同一with子句内部不能嵌套with子句。
5.当一个查询块名字和一个表名或其他的对象相同时,解析器从内向外搜索,优先使用子查询块名字。
6.with查询的结果列有别名,引用的时候必须使用别名或*。

  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
摘 要 随着网络信息的飞速发展,计算机逐渐受到人们的关注,网络媒体也受到越来越多公 司的青睐,其中,网站是传播媒体的好方法。当前有许多公司正在开发属于自己的网站 ,因此有必要研究网站建设。本文专门阐述了开发网站的PHP技术,并说明了PHP对Apac heWeb服务器上的适用性。数据库系统软件是可以管理方法,存储,求解和维护数据信息 的系统软件。每个动态网站都必须包含一个数据库,因此数据库的状态非常重要。在此 文中选择了Mysql数据库服务器端作为后台数据库,这样方便Web与数据库紧密联系起来 。在设计过程中,充分保证了系统软件编码的良好可读性、实用性、易扩展性等,便于 在中后期的维护和操作方便。而数据增添,删减,改正和检索的特性则由统一软件进行 管理和控制。数据库和PHP技术也是本文的阐述的主要对象。 本文使用PHP技术,数据库和相应的网站开发软件来解释网站的前端和后端设计,并 讨论其功能,以实现整个网站功能的使用。通过整个网站的设计,分析并说明了开发过 程中遇到的常见问题的解决方案。 关键词:游戏网站;PHP;Mysql Abstract With the rapid development of network information, computers gradually attract people's attention, and network media are also favored by more and more companies. Among them, websites are a good way to spread media.Many companies are currently developing their own websites, so it is necessary to study website construction. This article specifically elaborates on the PHP technology of developing websites, and explains the applicability of PHP to Apache Web server. Database system software is a system software that can manage methods, store, solve and maintain data information. Every dynamic website must contain a database, so the state of the database is very important.In this article, the Mysql database server is selected as the back-end database, which facilitates the close connection between the Web and the database. In the design process, it fully guarantees the good readability, practicability, and extensibility of the system software code, which is convenient for maintenance and operation in the middle and later stages. The characteristics of data addition, deletion, modification and retrieval are managed and controlled by unified software. Database and PHP technology are also the main objects of this article. This paper uses PHP technology database and corresponding website development software to illustrate the front-end and back-end design of the website, and discuss its functions to realize the use of the entire website.Through the design of the whole website, analysis and explain the comm

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值