mysql练习----More JOIN operations
This tutorial introduces the notion of a join. The database consists of three tables movie , actor and casting .
|
movie |
actor | casting |
|---|---|---|
| id | id | movieid |
| title | name | actorid |
| yr | ord | |
| director | ||
| budget | ||
| gross | ||

movie
| Field name | Type | Notes |
|---|---|---|
| id | INTEGER | An arbitrary unique identifier |
| title | CHAR(70) | The name of the film - usually in the language of the first release. |
| yr | DECIMAL(4) | Year of first release. |
| director | INT | A reference to the actor table. |
| budget | INTEGER | How much the movie cost to make (in a variety of currencies unfortunately). |
| gross | INTEGER | How much the movie made at the box office. |
Example
| id | title | yr | director | budget | gross |
|---|---|---|---|---|---|
| 10003 | "Crocodile" Dundee II | 1988 | 38 | 15800000 | 239606210 |
| 10004 | 'Til There Was You | 1997 | 49 | 10000000 |
actor
| Field name | Type | Notes |
|---|---|---|
| id | INTEGER | An arbitrary unique identifier |
| name | CHAR(36) | The name of the actor (the term actor is used to refer to both male and female thesps.) |
Example
| id | name |
|---|---|
| 20 | Paul Hogan |
| 50 | Jeanne Tripplehorn |
casting
| Field name | Type | Notes |
|---|---|---|
| movieid | INTEGER | A reference to the movie table. |
| actorid | INTEGER | A reference to the actor table. |
| ord | INTEGER | The ordinal position of the actor in the cast list. The
star of the movie will have ord value 1 the co-star will have value 2, ... |
Example
| movieid | actorid | ord |
|---|---|---|
| 10003 | 20 | 4 |
| 10004 | 50 | 1 |















mysql练习----More JOIN operations的更多相关文章
- MySQL关联left join 条件on与where不同
以下的文章主要讲述的是MySQL关联left join 条件on与where 条件的不同之处,我们现在有两个表,即商品表(products)与sales_detail(销售记录表).我们主要是通过这两 ...
- MySQL 的各种 join
table th:first-of-type { width: 200px; } join 类型 备注 left [outer] join right [outer] join union [all ...
- MySQL之LEFT JOIN中使用ON和WHRERE对表数据
背景 left join在我们使用mysql查询的过程中可谓非常常见,比如博客里一篇文章有多少条评论.商城里一个货物有多少评论.一条评论有多少个赞等等.但是由于对join.on.where等关键字的不 ...
- 记录一下使用MySQL的left join时,遇到的坑
# 现象 left join在我们使用mysql查询的过程中可谓非常常见,比如博客里一篇文章有多少条评论.商城里一个货物有多少评论.一条评论有多少个赞等等.但是由于对join.on.where等关键字 ...
- MySQL 通过semi join 优化子查询
半连接是MySQL 5.6.5引入的,多在子查询exists中使用,对外部row source的每个键值,查找到内部row source匹配的第一个键值后就返回,如果找到就不用再查找内部row sou ...
- MySQL的left join中on与where的区别
关于 “A LEFT JOIN B ON 条件表达式” 的一点提醒 ON 条件(“A LEFT JOIN B ON 条件表达式”中的ON)用来决定如何从 B 表中检索数据行,即使on中包含有A表中的列 ...
- mysql left( right ) join使用on 与where 筛选的差异
有这样的一个问题mysql查询使用mysql中left(right)join筛选条件在on与where查询出的数据是否有差异. 可能只看着两个关键字看不出任何的问题.那我们使用实际的例子来说到底有没有 ...
- mysql 跨库JOIN
现有两台MYSQL数据库 一台是192.168.1.1 端口3306 上有数据库DB1 有表TABLE1一台是192.168.1.2 端口3307 上有数据库DB2 有表TABLE2192.168.1 ...
- mysql关键字讲解(join 、order by、group by、having、distinct)
1.join 1.1 OUTER JOIN:想要包含右侧表中的所有行,以及左侧表中有匹配记录的行. 1.11 Mysql中有左连接(left join): ...
随机推荐
- 7-Flink的分布式缓存
分布式缓存 Flink提供了一个分布式缓存,类似于hadoop,可以使用户在并行函数中很方便的读取本地文件,并把它放在taskmanager节点中,防止task重复拉取. 此缓存的工作机制如下:程序注 ...
- 使用Domain-Driven创建Hypermedia API
在现实中我们会遇到各种各样的复杂场景,"There is not a right way" 用来描述API的设计方法再合适不过了,没有一种API设计方式可以应对所有的场景.区别于& ...
- git版本管理规范
一.基本开发流程: 二.分支命名 2.1主分支 ① master :随时可供在生产环境中部署的代码 ② dev: 保存当前稳定并且最新的开发分支(多人开发同一分支) 2.2辅助分支 主要用于新功能的并 ...
- 【原创】c++拷贝初始化和直接初始化的底层区别
说明:如果看不懂的童鞋,可以直接跳到最后看总结,再回头看上文内容,如有不对,请指出~ 环境:visual studio 2013(编译器优化关闭) 源代码 下面的源代码修改自http://blog.c ...
- mysql常用字符串操作函数大全,以及实例
今天在论坛中看到一个关于mysql的问题,问题如下 good_id cat_id12654 665,56912655 601,4722 goods_id是商品i ...
- thinkphp自动映射分析
thinkphp的字段映射功能可以隐藏表单中真正的字段名,自动映射到真正的数据库字段,如表单中input的提交的名字为mail,而数据库中存的是email实现的原理非常简单首先定义一个映射的数组,以下 ...
- Java——对象比较
前言 本篇博客主要梳理一下Java中对象比较的需要注意的地方,将分为以下几个方面进行介绍: ==和equals()方法 hashCode()方法和equals()方法 Comparator接口和Com ...
- tomcat通过一个端口号实现多域名访问
最近在一个项目中遇到这样的一个场景,在一台服务器一个tomcat一个端口配置多个域名.没想到解决方法这么简单,通过虚拟目录来实现. 修改tomcat安装路径下/conf下的server.xml vim ...
- PXE+kickstart无人值守安装CentOS 7
kickstart+cobbler系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 本文是PXE+kickstart无人值守安装CentOS ...
- Perl的比较操作符
比较操作符 perl的比较操作符和bash完全相反.数值比较采用符号,字符串比较采用字母. 数值 字符串 意义 ----------------------------- == eq 相等 != ne ...