我正在尝试对右表进行左连接。但是在左外连接上,结果显示左连接上的行数少于 LHS 表上的 select 语句??!
[hadoop-29:21000] > SELECT
> COUNT (*)
> FROM
> state_vectors_data4
> left OUTER JOIN position_data4 ON (state_vectors_data4.lastcontact = position_data4.maxtime
> AND state_vectors_data4.icao24 = position_data4.icao24)
> WHERE
> state_vectors_data4.time >= 1677628800
> AND state_vectors_data4.time < 1677628810
> AND state_vectors_data4.hour >= 1677628800
> AND state_vectors_data4.hour <= 1677632400
> AND state_vectors_data4.lat > 22.707434526056968
> AND state_vectors_data4.lat < 71.83985097021925
> AND state_vectors_data4.lon < -49.97631795370285
> AND state_vectors_data4.lon > -168.4528775341493
> AND position_data4.hour >= 1677628800
> AND position_data4.hour <= 1677632400;
+----------+
| count(*) |
+----------+
| 13260 |
+----------+
内部连接怎么可能返回小于 LHS 表上的 select 语句的行?我在这里错过了什么?
[hadoop-29:21000] > SELECT
> COUNT(*)
> FROM
> state_vectors_data4
>
> WHERE
> state_vectors_data4.time >= 1677628800
> AND state_vectors_data4.time < 1677628810
> AND state_vectors_data4.hour >= 1677628800
> AND state_vectors_data4.hour <= 1677632400
> AND state_vectors_data4.lat > 22.707434526056968
> AND state_vectors_data4.lat < 71.83985097021925
> AND state_vectors_data4.lon < -49.97631795370285
> AND state_vectors_data4.lon > -168.4528775341493;
+----------+
| count(*) |
+----------+
| 34210 |
+----------+
如果我进行左连接,左表中的行数是否会保持不变,如果没有匹配项,将从右表中添加一个空值?
右桌有额外条件
> AND position_data4.hour >= 1677628800
> AND position_data4.hour <= 1677632400;
所以你可能在这里丢失了一些记录