【问题标题】:What's the difference two tables side by side and join tables?两个表并排和连接表有什么区别?
【发布时间】:2020-03-24 11:24:51
【问题描述】:

我正在研究以下sql代码,试图理解但感到困惑:

当我们将两个表放在一起时,查询实际上做了什么?这和加入两个表有什么区别?谢谢!

select * from
        Logs, (select @count:=0,@record:=(SELECT num from Logs limit 0,1)) r

Logs 表如下所示:

+----+-----+
| Id | Num |
+----+-----+
| 1  |  1  |
| 2  |  1  |
| 3  |  1  |
| 4  |  2  |
| 5  |  1  |
| 6  |  2  |
| 7  |  2  |
+----+-----+

【问题讨论】:

    标签: mysql mysql-variables


    【解决方案1】:

    如果您不加入表格,它们的工作方式类似于cross join。左侧行数*右侧行数。

    See this.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-19
      • 1970-01-01
      • 2012-01-24
      • 2021-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多