According to the answers to the question on en.so, I came to the conclusion that the tools indicated there are what is required in my task, namely: to get the identifier of the "inserted" line, even if this did not happen in fact.
INSERT INTO `table` (`id`, `text`) VALUES (1, 'tra-ta-ta') ON DUPLICATE KEY UPDATE `id` = LAST_INSERT_ID(`id`); ... while the id column is PRIMARY KEY and AUTO_INCREMENT , and the text column is UNIQUE .
But based on this code, it turns out that the id will be replaced (the assignment sign, as it were, hints at this):
`id` = LAST_INSERT_ID(`id`) Does this mean that the value of the identifier in the corresponding column will indeed be replaced (albeit by the same value) with the corresponding consequences, such as, for example, ON UPDATE CASCADE for FOREIGN KEY for any connected table? And maybe ON DELETE CASCADE will work, as if using REPLACE instead of INSERT ? Then quite a disaster.
Am I right in my doubts, and if this is true, then how is it possible to solve the problem?
on duplicate update, it seems to me, is quite ordinary for those who are constantly working with the DBMS. - alexis031182