1

I want to update columns of a table whose values are NULL and I want to do this for 5 rows, but I'm getting the error : missing SET keyword

I am running the query in oracle SQL developer

The query I'm using is

UPDATE  top(5) table_name
set col1=value1,
col2=value2,
col3=value3 where col1=null;

Second query I used is

UPDATE  table_name  
set col1=value1,
col2=value2,
col3=value3 where col1=null and rownum<=5;
Arulkumar
  • 12,966
  • 14
  • 47
  • 68
Harshit Verma
  • 59
  • 1
  • 4
  • 1
    You should not use '=' to null, change it to 'IS NULL' instead. Find more explanation here:https://stackoverflow.com/questions/9581745/sql-is-null-and-null – Hana Jun 03 '22 at 09:00

1 Answers1

0

You can do this in below way:

UPDATE  table_name   
set (col1,col2,col3) = (select col1,col2,col3 from table_name where col1 is null and rownum<=5) 
where col1 is null;