Check out example codes for "sql server if exists update else insert". It will help you in understanding the concepts better.

Code Example 1

if exists(SELECT * from Student where FirstName='Akhil' and LastName='Mittal')            
BEGIN            
 update Student set FirstName='Anu' where FirstName='Akhil'  
End                    
else            
begin  
insert into Student values(1,'Akhil','Mittal',28,'Male',2006,'Noida','Tenth','LFS','Delhi')  
end 

Learn ReactJs, React Native from akashmittal.com