You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

两张空表执行Inner Join是否等同于Cross Join操作?

Are Inner Join and Cross Join Results Identical When Working With Two Empty Tables?

Great question! Let’s cut straight to the answer first: Yes, when you run an INNER JOIN or CROSS JOIN on two completely empty tables, the result will be the same—an empty result set with zero rows.

Let’s break down why this makes sense:

  • Cross Join Basics: A cross join returns the Cartesian product of the two tables. That means every row from the first table is paired with every row from the second. If Table A has 0 rows and Table B has 0 rows, the product is 0 * 0 = 0 rows—so you get nothing back.

  • Inner Join Basics: An inner join starts by computing the Cartesian product of the two tables, then filters the results to only keep rows that match your join condition. But if the initial Cartesian product has 0 rows (because both tables are empty), there’s nothing to filter. No matter what join condition you use (even something like 1=1), you still end up with 0 rows.

Here’s a quick SQL example to prove it:

-- Create two empty tables
CREATE TABLE EmptyTable1 (id INT);
CREATE TABLE EmptyTable2 (value VARCHAR(50));

-- Cross Join
SELECT * FROM EmptyTable1 CROSS JOIN EmptyTable2;
-- Result: 0 rows returned

-- Inner Join (with a typical condition)
SELECT * FROM EmptyTable1 INNER JOIN EmptyTable2 ON EmptyTable1.id = EmptyTable2.value;
-- Result: 0 rows returned

-- Even with an always-true condition
SELECT * FROM EmptyTable1 INNER JOIN EmptyTable2 ON 1=1;
-- Result: Still 0 rows returned

The key takeaway here is that when both tables are empty, there’s no data to pair or filter—so both operations end up producing the same empty result set.

内容的提问来源于stack exchange,提问作者Mrinal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:57:58