I understand little in SQL, please help in solving the problem:
Given:
- table table;
- fields id, name, email (id - UNIQUE);
- array of data transmitted from php to the request.
Task: write a request to add nonexistent and update existing records.
Something has already happened (the request itself):
INSERT INTO `table` (`id`, `name`, `email`) VALUES ('1-', 'oleg', 'qqq@mail.ru'), ('2-', 'dima', 'ggg@mail.ru'), ('3-', 'petr', 'mmm@mail.ru'), ('4-', 'anna', 'nnn@mail.ru') и так далее... ON DUPLICATE KEY UPDATE `name` = ????? `email` = ?????? From php:
<? // $arr - массив данных (порядка 10к строк формата: "('1-', 'oleg', 'qqq@mail.ru')") $mysqli->query(" INSERT INTO `table` (`id`, `name`, `email`) VALUES ".implode(",", $arr)." ON DUPLICATE KEY UPDATE `name` = ????? `email` = ?????? ") ?> Question: What should I write after "ON DUPLICATE KEY UPDATE" to update existing strings? Maybe there are other solutions to the problem?