0

I have table contains questions data. Also every question has test id, document id (dokuman_id), order (sira) and video data. I want to create a query that insert new row if there isn't a row has same test id, document id and order; else just update video field.

enter image description here

I know I could use ON DUPLICATE KEY if I want to do it with id(primart_key) column. But I need to control 3 duplicate column conditions as optimum as possible.

eneskomur
  • 91
  • 1
  • 13

1 Answers1

1

you should create index on test_id , dokuman_id , sira

INSERT INTO table (test_id , dokuman_id , sira , video) 
VALUES(:test_id , :dokuman_id , :sira , :video) 
ON DUPLICATE KEY UPDATE video = :video
Ali Faris
  • 17,754
  • 10
  • 45
  • 70