zoukankan      html  css  js  c++  java
  • MySQL数据库之多表查询cross join交叉连接

    交叉连接

    • 语法
      • select * from 表1 cross join 表2 on ...
      • 交叉连接如果没有连接条件返回笛卡尔积
      • 如果有连接条件和内连接是一样的
    MariaDB [sel]> select * from grades cross join resume;
    +-------+---------+------+----+-------+-----------+
    | name  | chinese | math | id | name  | skill     |
    +-------+---------+------+----+-------+-----------+
    | Sunny |      93 |   96 |  1 | Sunny | php       |
    | Sunny |      93 |   96 |  2 | Kimmy | php       |
    | Sunny |      93 |   96 |  3 | Jerry | php,mysql |
    | Jerry |      97 |   91 |  1 | Sunny | php       |
    | Jerry |      97 |   91 |  2 | Kimmy | php       |
    | Jerry |      97 |   91 |  3 | Jerry | php,mysql |
    | Marry |      95 |   94 |  1 | Sunny | php       |
    | Marry |      95 |   94 |  2 | Kimmy | php       |
    | Marry |      95 |   94 |  3 | Jerry | php,mysql |
    | Tommy |      98 |   94 |  1 | Sunny | php       |
    | Tommy |      98 |   94 |  2 | Kimmy | php       |
    | Tommy |      98 |   94 |  3 | Jerry | php,mysql |
    +-------+---------+------+----+-------+-----------+
    # `12 rows in set (0.001 sec)`
    
    • 交叉连接有连接表达式与内连接是一样的
    MariaDB [sel]> select * from grades cross join resume on grades.name=resume.name;
    +-------+---------+------+----+-------+-----------+
    | name  | chinese | math | id | name  | skill     |
    +-------+---------+------+----+-------+-----------+
    | Sunny |      93 |   96 |  1 | Sunny | php       |
    | Jerry |      97 |   91 |  3 | Jerry | php,mysql |
    +-------+---------+------+----+-------+-----------+
    # `2 rows in set (0.000 sec)`
    
  • 相关阅读:
    树——题解汇总
    element ui实现手动上传文件,且只能上传单个文件,并能覆盖上传
    浏览器缓存
    websocket协议
    session
    cookie
    作用域插槽
    时间格式化函数
    Neo4j快速入门
    线性空间
  • 原文地址:https://www.cnblogs.com/SharkJiao/p/14137841.html
Copyright © 2011-2022 走看看