Hive 无法在配置单元中执行条件插入

Hive 无法在配置单元中执行条件插入,hive,Hive,我有两张桌子。客户1和客户2 顾客1 身份证名称 1杰克 约翰 琼斯3号 客户2 身份证名称 Customer 2表是空的。现在,我必须检查客户2中是否存在一个特定的名称,如“jack”,并插入客户2中是否不存在一个名称“jack”。下面的查询应符合此目的。我假设ID是表之间链接的键,如果不是,您可以在连接条件中使用该名称 `insert into customer2 select customer1.* from customer1 left join customer2 on (

我有两张桌子。客户1和客户2

顾客1

身份证名称 1杰克 约翰 琼斯3号

客户2

身份证名称


Customer 2表是空的。现在,我必须检查客户2中是否存在一个特定的名称,如“jack”,并插入客户2中是否不存在一个名称“jack”。

下面的查询应符合此目的。我假设ID是表之间链接的键,如果不是,您可以在连接条件中使用该名称

  `insert into customer2 
select customer1.* 
from customer1 
left join customer2 
on (customer1.id=customer2.id) 
where customer1.name='jack' and isnull(customer2.id);`

你能为你自己试图解决的问题提供代码吗?如果没有代码,很难找到您想要实现的目标。另请参见以下答案:我使用的查询是:插入到表customer1 select*from customers where customers.name不在select name from customer1中;