----------------------siwuxie095

MySQL 多表查询回顾

以客户和联系人为例(一对多)

1、内连接

/*内连接写法一*/

select * from t_customer c,t_linkman l where c.cid=l.clid

/*内连接写法二(inner 可以省略不写)*/

select * from t_customer c inner join t_linkman l on c.cid=l.clid

2、左外连接

/*左外连接(outer 可以省略不写):左表的所有数据,右表的关联数据*/

select * from t_customer c left outer join t_linkman l on c.cid=l.clid

3、右外连接

/*右外连接(outer 可以省略不写):右表的所有数据,左表的关联数据*/

select * from t_customer c right outer join t_linkman l on c.cid=l.clid

【made by siwuxie095】

MySQL多表查询回顾的更多相关文章

  1. MySQL多表查询之外键、表连接、子查询、索引

    MySQL多表查询之外键.表连接.子查询.索引 一.外键: 1.什么是外键 2.外键语法 3.外键的条件 4.添加外键 5.删除外键 1.什么是外键: 主键:是唯一标识一条记录,不能有重复的,不允许为 ...

  2. Mysql 单表查询 子查询 关联查询

    数据准备: ## 学院表create table department( d_id int primary key auto_increment, d_name varchar(20) not nul ...

  3. (转)Mysql 多表查询详解

    MySQL 多表查询详解 一.前言  二.示例 三.注意事项 一.前言  上篇讲到mysql中关键字执行的顺序,只涉及了一张表:实际应用大部分情况下,查询语句都会涉及到多张表格 : 1.1 多表连接有 ...

  4. python 3 mysql 单表查询

    python 3 mysql 单表查询 1.准备表 company.employee 员工id id int 姓名 emp_name varchar 性别 sex enum 年龄 age int 入职 ...

  5. python3 mysql 多表查询

    python3 mysql 多表查询 一.准备表 创建二张表: company.employee company.department #建表 create table department( id ...

  6. Mysql 单表查询-排序-分页-group by初识

    Mysql 单表查询-排序-分页-group by初识 对于select 来说, 分组聚合(((group by; aggregation), 排序 (order by** ), 分页查询 (limi ...

  7. Mysql 单表查询where初识

    Mysql 单表查询where初识 准备数据 -- 创建测试库 -- drop database if exists student_db; create database student_db ch ...

  8. MySQL多表查询合并结果union all,内连接查询

    MySQL多表查询合并结果和内连接查询 1.使用union和union all合并两个查询结果:select 字段名 from tablename1 union select 字段名 from tab ...

  9. MySQL多表查询、事务、DCL:内含mysql如果忘记密码解决方案

    MySQL多表查询.事务.DCL 多表查询 * 查询语法: select 列名列表 from 表名列表 where.... * 准备sql # 创建部门表 CREATE TABLE dept( id ...

随机推荐

  1. consul 几个方便使用的类库

    consul 几个方便使用的类库 1. java  https://github.com/OrbitzWorldwide/consul-client   <dependency> < ...

  2. Apache + Tomcat + 连接器JK

    一 安装Apache 下载apache: https://www.apache.org/   ->  http://mirrors.cnnic.cn/apache/  -> http:// ...

  3. RK3288 查看ddr频率

    转载请注明出处:https://www.cnblogs.com/lialong1st/p/8515135.html RK3288 查看 ddr 当前频率的方式有两种,第一种是通过 adb 查看,第二种 ...

  4. C++ 命名空间解释

    using关键字 如果在程序中需要多次引用某个命名空间的成员,那么按照之前的说法,我们每次都要使用范围解析符来指定该命名空间,这是一件很麻烦的事情.为了解决这个问题,人们引入了using关键字.usi ...

  5. 嵌入ARM硬核的FPGA

    目前,在FPGA上嵌入ARM硬核的包括Xilinx的zynq系列以及Intel 的CYCLONEV系列. Zynq出来有一定市场,但是这个市场不是传统FPGA的主流市场,而是为了和微处理抢一些控制领域 ...

  6. struts2学习(14)struts2文件上传和下载(4)多个文件上传和下载

    四.多个文件上传: 五.struts2文件下载: 多个文件上传action com.cy.action.FilesUploadAction.java: package com.cy.action; i ...

  7. java 的一个hellow word 代码解释

    /* This is a simple Java program. Call this file "Example.java". */(上面是注释的方法) class Exampl ...

  8. [转][Java]Jsp入门

    <% response.getOutputStream().write("123".getBytes()); %> 新建一个 Web Project 项目,jsp 文件 ...

  9. 关于模拟admin实现stark组件的知识点

    一. url知识 还记得include分发么?里面的参数都可以有些什么? urlconf_module本质是返回的是模块路径对象 def include(arg, namespace=None, ap ...

  10. Php处理时间的函数

    1,字符串与时间: 例如 $time = strtotime("2007-3-5"); echo date("Y-m-d H:i:s",$time); 2,当前 ...