第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. Ajax的异步与同步(async)

    1.async值为true (异步)当ajax发送请求后,在等待server端返回的这个过程中,前台会继续 执行ajax块后面的脚本,直到server端返回正确的结果才会去执行success,也就是说 ...

  2. 5种必会的Java异步调用转同步的方法你会几种

    转载请注明本文地址:https://www.jianshu.com/p/f00aa6f66281 源码地址:https://gitee.com/sunnymore/asyncToSync Sunny先 ...

  3. ASCS HA

    Please let us know what do you mean by "the PAS can not be accessed", what error did you f ...

  4. Oracle创建pfile spfile 文件及其恢复

    1.Oralce在启动实例的时读取$ORACLE_HOME/dbs下面的初始化文件.初始化文件分为:A.静态参数文件PFILE,一般名为initSID.oraB.永久参数文件SPFILE,一般名为sp ...

  5. 部署一个基于python语言的web发布环境

    ---恢复内容开始--- 1) 一门面向对象的语言 2)拥有丰富的库 3)可移植性 4)免费.开源 5)简单易易学 可做软件开发.人工智能.web开发等等 部署流程: Cnetos7.5+Nginx+ ...

  6. [leetcode]59. Spiral Matrix II螺旋遍历矩阵2

    Given a positive integer n, generate a square matrix filled with elements from 1 to n^2 in spiral or ...

  7. printf 字符串格式化

    在将各种类型的数据构造成字符串时,sprintf 的强大功能很少会让你失望.由于sprintf 跟printf 在用法上几乎一样,只是打印的目的地不同而已,前者打印到字符串中,后者则直接在命令行上输出 ...

  8. 改变this的指向问题;

    用call()和apply()改变this的指向,那什么时候用this呢?(构造函数),那为什么要用构造函数呢?(为了生成对象). 1.解决函数内this指向的问题 (1)var that/_this ...

  9. win10系统配置jdk环境不能用%JAVA_HOME% 代替目录

    发现以前配好的java环境变量和tomcat环境变量全都清空了,在重新配置的时候总是出现问题,即在cmd命令窗口下,输入java,显示正常,输入java -version 也是显示正常,唯独输入jav ...

  10. js data日期初始化的5种方法

    var objDate=new Date([arguments list]);  参数形式有以下5种: 1)new Date("month dd,yyyy hh:mm:ss");  ...