0

I have used this query to update data

INSERT OVERWRITE TABLE record PARTITION(dated='03-08-2013')                    
     SELECT id, f_name, marks, CASE WHEN id=224 THEN 'KUMAR' ELSE l_name END AS l_name
     FROM record;

but creates some problem column miss managed l_name appeared in marks column. any help

Spudley
  • 166,037
  • 39
  • 233
  • 307

1 Answers1

0

Use your query like this:

INSERT OVERWRITE TABLE record PARTITION(dated='03-08-2013') 
SELECT id, f_name, marks, CASE WHEN id=224 THEN 'KUMAR' ELSE l_name END AS l_name
FROM record WHERE [_whereClause_];

Please see this Link for more clarification:

Community
  • 1
  • 1
Sandeep Singh
  • 7,790
  • 4
  • 43
  • 68
  • and there is no need to use Where Clause its just optional part u can use it or not. – Ashwani Sharma Aug 02 '13 at 04:36
  • Great, Please share your answer and resolution also. It will help others in future. – Sandeep Singh Aug 02 '13 at 05:53
  • Hello please make sure which column you want to update as I update l_name then write previous column after SELECT and rest of column after END AS like l_name,marks here is this code- INSERT OVERWRITE TABLE record PARTITION(dated='03-08-2013') SELECT id, f_name, CASE WHEN id=224 THEN 'KUMAR' ELSE l_name END AS l_name,marks FROM record; hope this will help thanks Regard:- Ashwani Sharma – Ashwani Sharma Aug 02 '13 at 10:56