码迷,mamicode.com
首页 > 数据库 > 详细

sql 入门经典(第五版) Ryan Stephens 学习笔记  第四部分:建立复杂的数据库查询

时间:2016-06-05 17:03:20      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

第十四章: 使用子查询定义未确定的数据

1、 子查询与select 结合使用

  select colum from table where column where  columnb=(select colum_name from ...);

2、   子查询与inset结合使用

  insert table1 select column1 from table2 where cloumn2>(select ......);

  将表二中满足条件的某几项 插入到表1 中,注: 插入的项数 = table1的column数

3、 子查询与 update 结合使用

4、 子查询与delete 结合使用

 

第十五章: 组合多个查询

1、 union 

  select id from stu union id from jobe ;        // 当两个table中id相同时,不重复输出。

2、 union all

  select id from stu union all id from jobe ;    // 当两个table中id相同时,重复输出。

sql 入门经典(第五版) Ryan Stephens 学习笔记  第四部分:建立复杂的数据库查询

标签:

原文地址:http://www.cnblogs.com/NeilZhang/p/5561018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!