2017-02-28 47 views
0
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中執行相同的查詢,請有人幫我解決。不能添加另一個表使用Impala中的選擇查詢

我得到以下錯誤:

Subqueries not supported in the selected list

+0

你會得到什麼錯誤? –

+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

+0

謝謝Gordon,但在更改列後仍然有效,感謝您的幫助! –

相關問題