第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_欢的更多相关文章

  1. 《mysql必知必会》学习_第20章_20180809_欢

    第20章:更新和删除数据 P140 update customers set_emails='elmer@fudd.com' where cust_id=10005; 更新多个列,用逗号隔开.注意被指 ...

  2. 《mysql必知必会》学习_第19章_20180809_欢

    第19章 插入数据 P132 insert into customers VALUES(NULL,'Pep E.Lapew','100 Main Street',,Los Angeles','CA', ...

  3. 《mysql必知必会》学习_第18章_20180807_欢

    第18章 全文本搜索 P121  #创建一个新表,对表的列进行定义,定义之后,MySQL自动维护该索引# create table productnotes ( note_id  int   NOT ...

  4. 《mysql必知必会》学习_第五章_20180730_欢

    使用的工具是wamp的Mysql. P29 select prod_name from products;  #在表products中选列prod_name,顺寻不是纯粹的随机,但是没有说明排列顺序, ...

  5. 《mysql必知必会》学习_第17章_20180807_欢

    第17章:组合查询 P114 select vend_id ,prod_id,prod_price from products where prod_price <=5 ; select ven ...

  6. 《mysql必知必会》学习_第16章_20180807_欢

    第16章:创建高级联结. P106 select concat(RTrim(vend_name),'(',RTrim(vend_country),')') as vend_title from ven ...

  7. 《mysql必知必会》学习_第15章_20180806_欢

    第15章:联结表 P98 外键:外键为某个表的一列A,同时这一列包含另一个表的主键值B(B属于A,等于或者小于的关系) P99 select vend_name,prod_name,prod_pric ...

  8. 《mysql必知必会》学习_第14章_20180806_欢

    第14章:使用子查询. 子查询是镶嵌在其他查询里面,相当其他的select查询的条件来. P91 select order_num from where prod_id='tnt2';   #检索条件 ...

  9. 《mysql必知必会》学习_第13章_20180803_欢

    第13章:分组过滤. P83 select count(*) as num_prods from products where vend_id=1003; #返回vend_id=1003的产品数目总值 ...

随机推荐

  1. Mac平台下部署UE4工程到iOS设备的流程

    1.开发环境 UE4.Xcode.iOS版本情况如下: 1.UE4:当前最新版本Unreal Engine 4.17.2. 2.Xcode:当前最新版本Xcode9.0. 3.iOS:当前最新版本iO ...

  2. javascript权威指南第1章Js概述js语言核心

    <html> <head> <script> function Point(x,y){ this.x=x; this.y=y; } ,); console.log( ...

  3. mysql连接测试java脚本

    JDBC.java import java.io.IOException; import java.io.InputStream; import java.sql.*; import java.uti ...

  4. JSON数据的解析和生成(C++)

    安装 "JSON for Modern C++" $ brew tap nlohmann/json $ brew install nlohmann_json 安装之后将/usr/l ...

  5. week07 13.3 NewsPipeline之 三News Deduper之 tf_idf 查重

    我们运行看结果 安装包sklearn 安装numpy 安装scipy 终于可以啦 我们把安装的包都写在文件里面吧 4行4列 轴对称 只需要看一半就可以 横着看 竖着看都行 数值越接近1 表示越相似 我 ...

  6. tensorflow报错error,tf.concat Expected int32, got list containing Tensors of type '_Message' instead

    参考:https://stackoverflow.com/questions/41813665/tensorflow-slim-typeerror-expected-int32-got-list-co ...

  7. cdn贝四层协议配置端口映射TCP端口转发

    端口映射就是将外网主机的IP地址的一个端口映射到内网中一台机器,提供相应的服务.当用户访问该IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上.端口映射有动态和静态之分 1.安装好节点后初 ...

  8. 监测SQLServer数据库中表的数据变化 方案

    sqlDependency提供了这样一种能力:当被监测的数据库中的数据发生变化时,SqlDependency会自动触发OnChange事件来通知应用程序,从而达到让系统自动更新数据(或缓存)的目的. ...

  9. Python中的线程详解

    线程 常用的方法 import threading import time def hello(name): print('Hello %s' % name) # 阻塞 time.sleep(5) p ...

  10. wdk驱动开发的特点

    本文介绍WDK开发的一些特点.与应用层开发的差异性,不能混为一谈. 一.函数的调用点 在内核编程中,一个函数往往有多个调用点,而应用层中一个函数一般只在main里面有调用点.内核函数调用点一般在: 1 ...