zoukankan      html  css  js  c++  java
  • MySQL--->多表查询

    多表查询

    • 连接查询
      • 同时涉及多个表的查询称为连接查询
      • 用来连接连个表的条件称为连接条件

    1. 多表查询---->内连接(INNER JOIN)    关键字: on
    • 语法:select  *   from  表1   inner  join  表2   on  表1 .  字段 = 表2 . 字段 ;

       2.多表查询---->左连接(LEFT JOIN)    关键字: on

    •  语法:select  *  from  表1  left  join  表2   on  表1 . 字段 = 表2 . 字段 ;

       3.多表查询---->右链接(RIGHT JOIN)    关键字   on

    • 语法:select  *  from  表1  right   join  表2  on  表1 . 字段 = 表2 . 字段 ;

          4:多表查询---->交叉链接(CROSS JOIN)    关键字   on

    •  语法:select *  from  表1  cross  join 表2 ;

       5.单列查询:select + 表名 . 列 ,列 from  表1  连接查询   表2(表 . 列 form 表)  表1 . 字段 = 表2 . 字段;

          6:多表查询------>where条件

    • select * from 表1 ,  表2   where a.stuno=b.stuno;  (where 后面跟的是两个表相同的条件)
    • select  表1 . 列 ,列   from  表2 , 表1  where  a.stuno=b.stuno;  (where 后面跟的是两个表相同的条件)
    • select  *  from   表1  , 表2  where  条件  and  条件   (准确查询)
    • select   聚合函数  from   表1  , 表2  where  条件  and  条件   (准确查询)
    • 三表查询: select   *   from  表1 , 表2 ,表3  where  表1 . 列 = 表3 . 列  and  表2 . 列 = 表3 . 列  and   条件 (准确查询)
    • select  列  ,列  from  表   where   条件  
  • 相关阅读:
    黑客术语1
    leetcode笔记--3 Niim game
    台湾ML笔记--1.2 formalize the learning probelm
    台湾ML笔记--1.1什么时候适合使用ML
    leetcode笔记--2 reverse string
    leetcode笔记--1 two-sum
    数据挖掘导论笔记1
    python基础----ipython快捷键
    记录新的开始
    编译器错误消息: CS1617: 选项“6”对 /langversion 无效
  • 原文地址:https://www.cnblogs.com/wyk1/p/13426333.html
Copyright © 2011-2022 走看看