1

我听说有 3 种类型的连接

我不确定确切的名字。谷歌搜索出现了各种术语,例如:

交叉连接、左连接、右连接、内连接、外连接、自连接......

谁能告诉我 MySQL 中总共有多少个连接。

4

3 回答 3

6

连接是

1. Inner Join or Equi join
2. Self Join
2. Outer Join
   outer join is again classified into
   a) Left Outer Join
   b) Right Outer Join
   c) Full Outer Join
3. Cross join
于 2013-03-13T05:19:32.227 回答
4

请参阅 SQL 连接:

JOIN 关键字在 SQL 语句中用于根据这些表中某些列之间的关系从两个或多个表中查询数据。

数据库中的表通常通过键相互关联。

主键是每行具有唯一值的列(或列组合)。每个主键值在表中必须是唯一的。目的是将数据绑定在一起,跨表,而不是重复每个表中的所有数据。

不同的 SQL JOIN

  1. JOIN:当两个表中至少有一个匹配时返回行
  2. LEFT JOIN:返回左表的所有行,即使右表没有匹配
  3. RIGHT JOIN:返回右表中的所有行,即使左表中没有匹配项
  4. FULL JOIN:当其中一个表中存在匹配时返回行

http://w3schools.com/sql/sql_join.asp

于 2013-03-13T05:17:14.510 回答
0

MySql 13.2.9.2。加入语法

join_table:
    table_reference [INNER | CROSS] JOIN table_factor [join_condition]
  | table_reference STRAIGHT_JOIN table_factor
  | table_reference STRAIGHT_JOIN table_factor ON conditional_expr
  | table_reference {LEFT|RIGHT} [OUTER] JOIN table_reference join_condition
  | table_reference NATURAL [{LEFT|RIGHT} [OUTER]] JOIN table_factor

SQL Server FROM (Transact-SQL)

<joined_table> ::= 
{
    <table_source> <join_type> <table_source> ON <search_condition> 
    | <table_source> CROSS JOIN <table_source> 
    | left_table_source { CROSS | OUTER } APPLY right_table_source 
    | [ ( ] <joined_table> [ ) ] 
}
<join_type> ::= 
    [ { INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } } [ <join_hint> ] ]
    JOIN
于 2013-03-13T05:24:27.927 回答