《mysql必知必会》学习_第22章_20180809_欢
第22章:使用视图,视图是虚拟的表,以表形式呈现的是你查询的结果。并不是说在数据库里面真的存在这个表,但是是真的存在这些数据。
select cust_name,cust_contact
from customers ,orders,orderitems
where customers.cust_id=orders.cust_id
and orderitems.orderitems.order_num=orders.order_num
and prod_id='tnt2';

P158
create view productcustomers as
select cust_name,cust_contact,prod_id from customers,orders,orderitems where
customers.cust_id=orders.cust_id and orderitems.order_num=orders.order_num;
#先建立名为productcustomers的视图,联结了三个表#
select cust_name,cust_contact from productcustomers where prod_id ='tnt2';
#先在上面的语句建立了视图productcustomers,然后在视图里面提取prod_id='tnt2'对应的cust_name,cust_contact #

其他的类似
《mysql必知必会》学习_第22章_20180809_欢的更多相关文章
- 《mysql必知必会》学习_第20章_20180809_欢
第20章:更新和删除数据 P140 update customers set_emails='elmer@fudd.com' where cust_id=10005; 更新多个列,用逗号隔开.注意被指 ...
- 《mysql必知必会》学习_第19章_20180809_欢
第19章 插入数据 P132 insert into customers VALUES(NULL,'Pep E.Lapew','100 Main Street',,Los Angeles','CA', ...
- 《mysql必知必会》学习_第18章_20180807_欢
第18章 全文本搜索 P121 #创建一个新表,对表的列进行定义,定义之后,MySQL自动维护该索引# create table productnotes ( note_id int NOT ...
- 《mysql必知必会》学习_第五章_20180730_欢
使用的工具是wamp的Mysql. P29 select prod_name from products; #在表products中选列prod_name,顺寻不是纯粹的随机,但是没有说明排列顺序, ...
- 《mysql必知必会》学习_第17章_20180807_欢
第17章:组合查询 P114 select vend_id ,prod_id,prod_price from products where prod_price <=5 ; select ven ...
- 《mysql必知必会》学习_第16章_20180807_欢
第16章:创建高级联结. P106 select concat(RTrim(vend_name),'(',RTrim(vend_country),')') as vend_title from ven ...
- 《mysql必知必会》学习_第15章_20180806_欢
第15章:联结表 P98 外键:外键为某个表的一列A,同时这一列包含另一个表的主键值B(B属于A,等于或者小于的关系) P99 select vend_name,prod_name,prod_pric ...
- 《mysql必知必会》学习_第14章_20180806_欢
第14章:使用子查询. 子查询是镶嵌在其他查询里面,相当其他的select查询的条件来. P91 select order_num from where prod_id='tnt2'; #检索条件 ...
- 《mysql必知必会》学习_第13章_20180803_欢
第13章:分组过滤. P83 select count(*) as num_prods from products where vend_id=1003; #返回vend_id=1003的产品数目总值 ...
随机推荐
- python3:实现字符串的全排列(有重复字符)
抛出问题 求任意一个字符串的全排列组合,例如a='123',输出 123,132,213,231,312,321. 解决方案 #字符串任意两个位置字符交换 def str_replace(str, x ...
- spring 之 注入之 by name or by type, or both ?
@Autowired 和 @Qualifier 使用xml 注入的时候, 我们可以指定 autowire=“byType” 或“byName” . 但是使用 注解的时候, @Autowired 只 ...
- Visual Studio资源汇总
Visual Studio 2015:http://tieba.baidu.com/p/3442930798Visual Studio 2013:http://tieba.baidu.com/p/34 ...
- Spring事务隔离级别和传播性
事务的隔离级别也分为四种: read uncommited(读未提交). read commited(读提交). read repeatable(读重复). serializable(序列化), 这四 ...
- LeetCode OJ 129. Sum Root to Leaf Numbers
题目 Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a num ...
- 自定义模块和grains
一.自定义模块 saltstack有很多模块,模块的源码文件是在salt项目的:salt/modules.py; salt linux-node2-computer sys.doc 查看有哪些mo ...
- R语言-箱型图&热力图
1.箱型图 boxplot()函数 > metals<-read.csv("metals.csv",header=TRUE) #读取文件和列名 > boxplot ...
- 2018年秋季学期面向对象程序设计(JAVA)课程总结
2018年秋季学期面向对象程序设计(JAVA)课程总结 时值2018年年末,按惯例对本学期教学工作小结如下: 1. 教学资源与教学辅助平台 教材:凯 S.霍斯特曼 (Cay S. Horstmann) ...
- 图像的几何变换——OpenCV-Python Tutorials
原文地址http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_geometric_tran ...
- Pandas合并数据集之concat、combine_first方法
轴向连接(concat) Numpy import numpy as np import pandas as pd from pandas import Series arr = np.arange( ...