学习笔记6.15
来源:互联网 发布:东汉国力 知乎 编辑:程序博客网 时间:2024/05/21 01:58
--给表名起别名select cust_name,cust_contactfrom customers c,orders o,orderitems oiwhere c.cust_id=o.cust_idand oi.order_num=o.order_numand prod_id='RGAN01';--oracle无as关键字--自然联结select c.*,o.order_num,o.order_date,oi.prod_id,oi.quantity,oi.item_pricefrom customers c,orders o,orderitems oiwhere c.cust_id=o.cust_idand oi.order_num=o.order_numand prod_id='RGAN01';--内联结select customers.cust_id,orders.order_numfrom customers inner join orderson customers.cust_id=orders.cust_id;--外联结select customers.cust_id,orders.order_numfrom customers left outer join orderson customers.cust_id=orders.cust_id;select customers.cust_id,orders .order_numfrom orders full outer join customerson Orders.cust_id=customers.cust_id;/*left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录inner join(等值连接) 只返回两个表中联结字段相等的行*/select customers.cust_id,orders .order_numfrom orders right outer join customerson Orders.cust_id=customers.cust_id;select customers.cust_id,count(orders.order_num) num_ordfrom customers inner join orderson customers.cust_id=orders.cust_idgroup by customers.cust_id;select customers.cust_id,count(orders.order_num) num_ordfrom customers left outer join orderson customers.cust_id=orders.cust_idgroup by customers.cust_id;
0 0
- 学习笔记6.15
- 学习笔记?
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- iOS开发- UICollectionView详解+实例
- 唯一可译码/单义代码
- 无聊的6.9
- 免费馅饼
- 学习笔记6.11
- 学习笔记6.15
- leetcode--Reverse Words in a String
- 百度质量部2015测试开发面试记录
- 【JS】全选、不选、反选复选框(模板)
- HDu 1001 Sum Problem
- Apache Rewrite重写模块(一):一个入门的例子
- 菜单栏显示效果
- 2015061908 - 人来人往
- uva10635 王子和公主(把lcs转化为lis)