提取表和子查询的区别(derived table vs subqueries)

翻译 2013年12月05日 12:06:08

子查询,大家再熟悉不过了,例如

select employee_name
from employee
where employee_salary >

(select avg(employee_salary)
from employee
)

下面这也是一个子查询,没用到where语句。

INSERT INTO math_study_group(id, name)
SELECT id, name
FROM student_details WHERE subject= 'Math'


下面粗体部分是提取表(derived table)

delete from id  where Id not in

 (select min(id)

from

(select id,peopleId from people)as a 

GROUP by peopleId );

两者的区别就是

- derived tables are used in the FROM clause
- subqueries are used in the WHERE clause, but can also
be used to select from one table and insert into
another as we showed above

翻译过来就是

提取表是用在 from 语句中的。

子查询是用在 where语句中的,但是也可以用在从一张表中查询,然后插入到另一张表,就像上面展示的那个例子一样。



相关文章推荐

Esper事件处理引擎_12_EPL 语法_5_Subqueries子查询

官方地址:http://www.espertech.com Esper 事件引擎栏目:http://blog.csdn.net/xiaohulunb/article/category...

Mysql两个查询结果相加?错误:Every derived table must have its own alias

查询结果求和,mysql错误:Every derived table must have its own alias

Every derived table must have its own alias

Every derived table must have its own alias 这主要是SQL语句的语法错误: select * from (select a.* from temperatu...

oracle sql 多表 嵌套子查询 连接查询, join where exist in 的区别

sql中exits和in的区别 转:http://hi.baidu.com/delphi_relive/blog/item/d7c0034a49c4932208f7ef21.html in 和...
  • wguoyong
  • wguoyong
  • 2011年11月12日 17:02
  • 12821

Every derived table must have its own alias

如下SQL语句: SELECT * FROM ( SELECT ID,URL FROM alone_action WHERE STATE = '1' ) 在Oracle中可以执行,但在M...

oracle sql 多表连接和子查询

  • 2011年12月18日 11:20
  • 339KB
  • 下载

oracle中的相关子查询(correlated subqueries)

http://blog.163.com/wkyuyang_001/blog/static/10802122820091751358252/ oracle中的相关子查询(correlate...

10.sql.server.2005.多表查询和子查询

  • 2010年07月03日 13:30
  • 27.18MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:提取表和子查询的区别(derived table vs subqueries)
举报原因:
原因补充:

(最多只允许输入30个字)