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

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

      <tfoot id='vqXN0'></tfoot>

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

      <legend id='vqXN0'><style id='vqXN0'><dir id='vqXN0'><q id='vqXN0'></q></dir></style></legend>

      这两种连接表方法之间的区别?

      Difference between these two joining table approaches?(这两种连接表方法之间的区别?)
        <tbody id='1nNes'></tbody>

          • <bdo id='1nNes'></bdo><ul id='1nNes'></ul>

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

                <small id='1nNes'></small><noframes id='1nNes'>

                <legend id='1nNes'><style id='1nNes'><dir id='1nNes'><q id='1nNes'></q></dir></style></legend>

                本文介绍了这两种连接表方法之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                假设我们有两个表,UsersPosts.user_idPosts 表中的外键,是Users 表中的主键.

                Consider we have two tables, Users and Posts. user_id is the foreign key in Posts table and is primary key in Users table.

                这两个sql查询有什么区别?

                Whats the difference between these two sql queries?

                select user.name, post.title 
                  from users as user, posts as post 
                 where post.user_id = user.user_id;
                

                对比

                select user.name, post.title 
                  from users as user join posts as post using user_id;
                

                推荐答案

                除了语法之外,对于小片段,它们的工作方式完全相同.但如果可能,请始终使用 ANSI-JOIN 编写新查询.

                Other than syntax, for the small snippet, they work exactly the same. But if at all possible, always write new queries using ANSI-JOINs.

                从语义上来说,逗号表示法是用来产生两个表之间的CARTESIAN积,即产生一个A表所有记录和B表所有记录的矩阵,所以有4条记录和6条记录的两张表分别产生24记录.使用 WHERE 子句,您可以从这个笛卡尔积中选择您真正想要的行.然而,MySQL 并没有真正贯彻并制作这个巨大的矩阵,但在语义上这就是它的意思.

                As for semantically, the comma notation is used to produce a CARTESIAN product between two tables, which means produce a matrix of all records from table A with all records from table B, so two tables with 4 and 6 records respectively produces 24 records. Using the WHERE clause, you can then pick the rows you actually want from this cartesian product. However, MySQL doesn't actually follow through and make this huge matrix, but semantically this is what it means.

                JOIN 语法是 ANSI 标准,它更清楚地定义了表的交互方式.通过将 ON 子句放在 JOIN 旁边,可以清楚地说明是什么将两个表联系在一起.

                A JOIN syntax is the ANSI standard that more clearly defines how tables interact. By putting the ON clause next to the JOIN, it makes it clear what links the two tables together.

                在功能上,它们将对您的两个查询执行相同的操作.当您开始使用其他 [OUTER] JOIN 类型时,区别就出现了.

                Functionally, they will perform the same for your two queries. The difference comes in when you start using other [OUTER] JOIN types.

                特别是对于 MySQL,逗号符号确实有一个区别

                For MySQL specifically, comma-notation does have one difference

                STRAIGHT_JOIN 与 JOIN 类似,只是左表总是在右表之前被读取.这可用于连接优化器将表按错误顺序排列的那些(少数)情况.

                STRAIGHT_JOIN is similar to JOIN, except that the left table is always read before the right table. This can be used for those (few) cases for which the join optimizer puts the tables in the wrong order.

                然而,寄希望于这一点不明智区别.

                However, it would not be wise to bank on this difference.

                这篇关于这两种连接表方法之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                SQL query to group by day(按天分组的 SQL 查询)
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                <i id='q6kLb'><tr id='q6kLb'><dt id='q6kLb'><q id='q6kLb'><span id='q6kLb'><b id='q6kLb'><form id='q6kLb'><ins id='q6kLb'></ins><ul id='q6kLb'></ul><sub id='q6kLb'></sub></form><legend id='q6kLb'></legend><bdo id='q6kLb'><pre id='q6kLb'><center id='q6kLb'></center></pre></bdo></b><th id='q6kLb'></th></span></q></dt></tr></i><div id='q6kLb'><tfoot id='q6kLb'></tfoot><dl id='q6kLb'><fieldset id='q6kLb'></fieldset></dl></div>

                    <tfoot id='q6kLb'></tfoot>

                    • <small id='q6kLb'></small><noframes id='q6kLb'>

                          <tbody id='q6kLb'></tbody>
                        • <bdo id='q6kLb'></bdo><ul id='q6kLb'></ul>
                        • <legend id='q6kLb'><style id='q6kLb'><dir id='q6kLb'><q id='q6kLb'></q></dir></style></legend>