• <bdo id='YcuBW'></bdo><ul id='YcuBW'></ul>

    1. <legend id='YcuBW'><style id='YcuBW'><dir id='YcuBW'><q id='YcuBW'></q></dir></style></legend>

        <small id='YcuBW'></small><noframes id='YcuBW'>

      1. <i id='YcuBW'><tr id='YcuBW'><dt id='YcuBW'><q id='YcuBW'><span id='YcuBW'><b id='YcuBW'><form id='YcuBW'><ins id='YcuBW'></ins><ul id='YcuBW'></ul><sub id='YcuBW'></sub></form><legend id='YcuBW'></legend><bdo id='YcuBW'><pre id='YcuBW'><center id='YcuBW'></center></pre></bdo></b><th id='YcuBW'></th></span></q></dt></tr></i><div id='YcuBW'><tfoot id='YcuBW'></tfoot><dl id='YcuBW'><fieldset id='YcuBW'></fieldset></dl></div>
      2. <tfoot id='YcuBW'></tfoot>

        INNER JOIN ON vs WHERE 子句

        时间:2023-08-19
          <bdo id='ubNDa'></bdo><ul id='ubNDa'></ul>

            • <legend id='ubNDa'><style id='ubNDa'><dir id='ubNDa'><q id='ubNDa'></q></dir></style></legend>
                <tbody id='ubNDa'></tbody>

                <small id='ubNDa'></small><noframes id='ubNDa'>

                <i id='ubNDa'><tr id='ubNDa'><dt id='ubNDa'><q id='ubNDa'><span id='ubNDa'><b id='ubNDa'><form id='ubNDa'><ins id='ubNDa'></ins><ul id='ubNDa'></ul><sub id='ubNDa'></sub></form><legend id='ubNDa'></legend><bdo id='ubNDa'><pre id='ubNDa'><center id='ubNDa'></center></pre></bdo></b><th id='ubNDa'></th></span></q></dt></tr></i><div id='ubNDa'><tfoot id='ubNDa'></tfoot><dl id='ubNDa'><fieldset id='ubNDa'></fieldset></dl></div>
                <tfoot id='ubNDa'></tfoot>

                1. 本文介绍了INNER JOIN ON vs WHERE 子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  为简单起见,假设所有相关字段都是NOT NULL.

                  For simplicity, assume all relevant fields are NOT NULL.

                  你可以这样做:

                  SELECT
                      table1.this, table2.that, table2.somethingelse
                  FROM
                      table1, table2
                  WHERE
                      table1.foreignkey = table2.primarykey
                      AND (some other conditions)
                  

                  否则:

                  SELECT
                      table1.this, table2.that, table2.somethingelse
                  FROM
                      table1 INNER JOIN table2
                      ON table1.foreignkey = table2.primarykey
                  WHERE
                      (some other conditions)
                  

                  这两个在MySQL中是否以相同的方式工作?

                  Do these two work on the same way in MySQL?

                  推荐答案

                  INNER JOIN 是您应该使用的 ANSI 语法.

                  INNER JOIN is ANSI syntax that you should use.

                  它通常被认为更具可读性,尤其是当您加入大量表格时.

                  It is generally considered more readable, especially when you join lots of tables.

                  也可以在需要时轻松替换为 OUTER JOIN.

                  It can also be easily replaced with an OUTER JOIN whenever a need arises.

                  WHERE 语法更面向关系模型.

                  The WHERE syntax is more relational model oriented.

                  两个表的结果 JOINed 是应用过滤器的表的笛卡尔积,过滤器只选择连接列匹配的那些行.

                  A result of two tables JOINed is a cartesian product of the tables to which a filter is applied which selects only those rows with joining columns matching.

                  使用 WHERE 语法更容易看到这一点.

                  It's easier to see this with the WHERE syntax.

                  就您的示例而言,在 MySQL(以及通常的 SQL)中,这两个查询是同义词.

                  As for your example, in MySQL (and in SQL generally) these two queries are synonyms.

                  另外,请注意 MySQL 还有一个 STRAIGHT_JOIN 子句.

                  Also, note that MySQL also has a STRAIGHT_JOIN clause.

                  使用这个子句,可以控制JOIN顺序:外循环扫描哪个表,内循环扫描哪个表.

                  Using this clause, you can control the JOIN order: which table is scanned in the outer loop and which one is in the inner loop.

                  您无法在 MySQL 中使用 WHERE 语法来控制这一点.

                  You cannot control this in MySQL using WHERE syntax.

                  这篇关于INNER JOIN ON vs WHERE 子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:MySQL ERROR 1045 (28000):用户“bill"@“localhost&quo 下一篇:我可以将多个 MySQL 行连接到一个字段中吗?

                  相关文章

                  最新文章

                    <tfoot id='IQlc4'></tfoot>

                    <small id='IQlc4'></small><noframes id='IQlc4'>

                      <i id='IQlc4'><tr id='IQlc4'><dt id='IQlc4'><q id='IQlc4'><span id='IQlc4'><b id='IQlc4'><form id='IQlc4'><ins id='IQlc4'></ins><ul id='IQlc4'></ul><sub id='IQlc4'></sub></form><legend id='IQlc4'></legend><bdo id='IQlc4'><pre id='IQlc4'><center id='IQlc4'></center></pre></bdo></b><th id='IQlc4'></th></span></q></dt></tr></i><div id='IQlc4'><tfoot id='IQlc4'></tfoot><dl id='IQlc4'><fieldset id='IQlc4'></fieldset></dl></div>
                      <legend id='IQlc4'><style id='IQlc4'><dir id='IQlc4'><q id='IQlc4'></q></dir></style></legend>
                        <bdo id='IQlc4'></bdo><ul id='IQlc4'></ul>