Answer the question
In order to leave comments, you need to log in
How to implement (SQL) mass update of table cells with binding by row id?
There is a table with many columns (10). PRIMARY KEY - id
It is necessary to update the data in some columns by binding to id. Bulk, per request.
id should remain the same.
Googled and tried the query below.
Execution doesn't work
Affected rows: 0 Found rows: 0 Warnings: 0
INSERT INTO tab_copy (`id`, `dat`, `status`) VALUES (1, 'hf',2), (2,'2222',2), (3,'3333',2) ON DUPLICATE KEY
UPDATE `id`= VALUES(`id`)
Answer the question
In order to leave comments, you need to log in
If `id` is PRIMARY KEY or UNIQUE, then it does not need to be changed upon collision.
... ON DUPLICATE KEY UPDATE `dat`= VALUES(`dat`), `status` = VALUES(`status`)
Update id = id
Without values.
Should work.
Also try replace instead of insert and without on duplicate...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question