I have a table to store client's answers.I want to use one mysql query to insert or update this table. My Table name : questionform_answer and columns > ClientID QuestionID OptionID
Each client can only have one same question id.For example
 ClientID QuestionID OptionID
    1         1         1
    1         2         5
    2         1         3
I want to update OptionID if already exist ClientID and QuestionID.I don't want to use select query so taking so time. I tried
     ON KEY UPDATE
     Replace Into
But I could not. I use php so I tried first update query and if mysqli return fail insert row but it is also slow. MY insert and update code :
   Insert Into questionform_answer (ClientID,QuestionID,OptionID) values 
   ('$ClientID','$soruid','$cevapid')
   Update questionform_answer set OptionID='$cevapid' where 
   ClientID='$ClientID' and QuestionID='$soruid'
 
     
     
    