Does MYSQL overwrite the same value column when updating?

When updating a table in mysql, for example:

user table

 user_id | user_name 1 John 2 Joseph 3 Juan 

If I run a query

 UPDATE `user` SET user_name = 'John' WHERE user_id = 1 

Will MYSQL repeat the same value or ignore it since it has the same content?


This is a Q & A question. The question I have done since Qaru encourages it, I think it will be useful in the future for the same programmers with the same question.

+5
source share
1 answer

As follows from the MYSQL Manual for the UPDATE statement ,

If you set the column to the value that it currently has, MySQL notices this and does not update it.

So, if you run this query, MYSQL will understand that the value you are trying to apply is the current value for the specified column and will not write anything to the database.

+10
source

Source: https://habr.com/ru/post/1242874/


All Articles