When reading legacy code, I found a SQL query to MySQL of this type:
INSERT INTO table (field1, field2, field3) VALUES (field1 = value1, field1 = value2, field3 = value3 ); As far as I understand, in MySQL there are two options for processing an insert request (if you do not take into account the option with INSERT ... SELECT ):
(one)
INSERT INTO table (field1, field2, field3) VALUES (value1, value2, value3); and 2)
INSERT INTO table SET field1 = value1, field2 = value2, field3 = value3; This second option, in my opinion, is very good, if there are a lot of fields filled in by the request - you are not tied to the order of the fields in the table and you can see which value belongs to which field.
The variant, similar to the example of the Legacy code, I did not see in the manual. There is a strong suspicion that besides simply specifying the name of a field, such a construction can be used in some other way. Or is it just a redundant code that can be cleaned and reduced to either the standard version (1) or the MySQL-specific version (2) ?
INSERT INTO table SET field1 = value1, field2 = value2, field3 = value3;But here it is:UPDATE table SET field1 = value1, field2 = value2, field3 = value3;- Andrey Arshinov