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)
Above is my query I have executed the same query in Mysql but I cant execute the same in Impala, someone please help me out.
I get the following error:
Subqueries not supported in the selected list
Try 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;
Note that you don't need select distinct
in the subqueries.