不能在impala中使用select查询添加另一个表

bpzcxfmw  于 2021-06-26  发布在  Impala
关注(0)|答案(1)|浏览(349)
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中执行相同的查询,有人请帮助我。
我得到以下错误:
所选列表中不支持子查询

6ioyuze2

6ioyuze21#

尝试 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 在子查询中。

相关问题