从 mysql 查询在配置单元中实现不等式连接
Implementing inequality join in hive from mysql query
我正在尝试在 mysql 中编写的配置单元中实现一个查询。我知道配置单元不支持 ON 条件下的不等式连接。下面是我的代码,并告诉我一种实现它的方法。
Select test1.a,
test2.b,
test4.c,
dummy.c
from
test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id and test3 != 'Archive'
join test4 on test3.id = test4.id and test4 = 'XYZ'
left outer join
(select test1.a,
test2,b
test3.c
from test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id) dummy
on test3.id = dummy.id
**and (test4.id != 1001 or dummy.c = TRUE)**
left join test5 on test3.id= test5.id
and dummy.c = TRUE
现在用 * 突出显示的条件是我需要知道如何在配置单元中实现它的部分,因为我无法在 ON 条件下实现它,如果我将它放在子句结果不匹配的地方。
任何在配置单元中重写它的建议将不胜感激。
我在 SELECT 语句中使用不等式条件作为 case 语句,用于从 LEFT JOIN 中选择的列。
下面是代码-
Select test1.a,
test2.b,
test4.c,
case when (test4.id != 1001 or nvl(dummy.c , False))= TRUE then dummy.c end as c0
from
test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id and test3 != 'Archive'
join test4 on test3.id = test4.id and test4 = 'XYZ'
left outer join
(select test1.a,
test2,b
test3.c
from test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id) dummy
on test3.id = dummy.id
left join test5 on test3.id= test5.id
and dummy.c = TRUE
我正在尝试在 mysql 中编写的配置单元中实现一个查询。我知道配置单元不支持 ON 条件下的不等式连接。下面是我的代码,并告诉我一种实现它的方法。
Select test1.a,
test2.b,
test4.c,
dummy.c
from
test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id and test3 != 'Archive'
join test4 on test3.id = test4.id and test4 = 'XYZ'
left outer join
(select test1.a,
test2,b
test3.c
from test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id) dummy
on test3.id = dummy.id
**and (test4.id != 1001 or dummy.c = TRUE)**
left join test5 on test3.id= test5.id
and dummy.c = TRUE
现在用 * 突出显示的条件是我需要知道如何在配置单元中实现它的部分,因为我无法在 ON 条件下实现它,如果我将它放在子句结果不匹配的地方。 任何在配置单元中重写它的建议将不胜感激。
我在 SELECT 语句中使用不等式条件作为 case 语句,用于从 LEFT JOIN 中选择的列。 下面是代码-
Select test1.a,
test2.b,
test4.c,
case when (test4.id != 1001 or nvl(dummy.c , False))= TRUE then dummy.c end as c0
from
test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id and test3 != 'Archive'
join test4 on test3.id = test4.id and test4 = 'XYZ'
left outer join
(select test1.a,
test2,b
test3.c
from test1 join test2 on test1.id = test2.id and test2 != 'ABC'
join test3 on test1.id = test2.id) dummy
on test3.id = dummy.id
left join test5 on test3.id= test5.id
and dummy.c = TRUE