无法在Impala中使用select查询添加另一个表

时间:2017-02-28 11:58:54

标签: mysql sql hiveql impala

INSERT INTO admin_userhistroy(sno,UserDetails_ID,UserMessage,SystemMessage_ID,insdate,STATUS,UserDetails_MsgTo_ID,License_Status)
VALUES ('1',(SELECT DISTINCT id FROM admin_userdetails WHERE token = 'ABCDE1' LIMIT 1)
,'New User is Created','4',cast(NOW() as string),'Y',cast((SELECT DISTINCT ID FROM admin_userdetails WHERE UserName = 'cangoadmin' AND token ='ABCDE1' LIMIT 1)as string)
,NULL)

上面是我的查询我在Mysql中执行了相同的查询,但是我无法在Impala中执行相同的操作,有人请帮帮我。

我收到以下错误:

  

所选列表中不支持子查询

1 个答案:

答案 0 :(得分:1)

尝试insert . . . select

INSERT INTO admin_userhistroy(sno,U serDetails_ID, UserMessage, SystemMessage_ID, insdate, STATUS, UserDetails_MsgTo_ID, License_Status)
    SELECT '1', x.id, 'New User is Created', '4',
           cast(NOW() as string), 'Y', y.id
    FROM (SELECT id FROM admin_userdetails WHERE token = 'ABCDE1' LIMIT 1) x CROSS JOIN
         (SELECT CAST(ID as string) as id FROM admin_userdetails WHERE UserName = 'cangoadmin' AND token ='ABCDE1' LIMIT 1) y;

请注意,子查询中不需要select distinct