A
A
ART42018-02-23 00:50:29
MySQL
ART4, 2018-02-23 00:50:29

ID AUTO_INCREMENT how to make friends ON DUPLICATE KEY UPDATE?

I have a table where
ID is AUTO_INCREMENT
What should be inserted into the code where id=id <- here
So that if only by name searched and replaced or added to the database? The skull is about to burst, I can't smoke it.
Parsing parses, id automatically adds the name of the product, if the id is cut down and is the same, then it replaces, if not the same id, then it doesn’t matter what product name it will add anyway ...

INSERT INTO s_products SET id=id, name="%Название%" ON DUPLICATE KEY UPDATE name=VALUES(`name`);

5a8f3aee32f6c531803087.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2018-02-23
@ART4

According to the description, I did not understand what is needed. ON DUPLICATE KEY looks at unique indexes, if it is necessary to look only at name, then this field must be given a unique index, and ID should not be passed for INSERT at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question