Home  >  Article  >  Database  >  How to learn MySQL? Use of update in MySQL and MySQL update

How to learn MySQL? Use of update in MySQL and MySQL update

黄舟
黄舟Original
2017-08-02 09:27:491501browse

As mentioned before, the setting up environment of MySQL and how to use select to query data in MySQL. Next, based on the experience in this section, I will briefly explain how to update data in MySQL. If you want to update it, of data.

In MySQL, use the update keyword to update data.

1. First of all, let’s briefly describe why there is an update function. For example, we all have Space has a function called posting articles. If there is no update function, it will result in that your article can never be modified after it is submitted and saved. You said that I can save 100% correct articles when I write them. But , what if you want to change? So, there is the keyword update.

How to learn MySQL? Use of update in MySQL and MySQL update

2. Let’s look at the first case first. Here we only explain the case and do not analyze the principle. First we We need to be clear about what we do. We want to update data, so we need to use the syntax structure of update. Before this step, we need to write about the current environment changes. First, you need to have a library, a table, and There is data, but there is no data. How can you update the data you want to update? Then if there is a database, tables and data, you can operate on the numbers.

How to learn MySQL? Use of update in MySQL and MySQL update

How to learn MySQL? Use of update in MySQL and MySQL update

3. Do the first operation: update the content of content to content. Here, it is a simple modification, and then modify the data in all the content fields in the table. The fields will be changed to the value of content. Modify it to content. This is the simplest case of updating data. However, this is generally not practical. During the development process, I rarely use this situation. Because some tables have not one or two pieces of data, it may be Millions of data. Just update it and it will make you cry.

The first picture is to query the data and then perform the update. Then you will find that the values ​​​​of all the content fields in the table are It has become content.

How to learn MySQL? Use of update in MySQL and MySQL update

How to learn MySQL? Use of update in MySQL and MySQL update

4. What if we don’t update all of them? We just want to update certain pieces of data, can we not? Can it be done? The answer is definitely yes. Here update can also use filter conditions like select, that is, use the keyword where. For example, we want to change the data content of id = 1 to, 'This is the content of id1'

How to learn MySQL? Use of update in MySQL and MySQL update

5. When updating, especially under the console, sometimes you will find that you have already updated, and after the update , query, but if you cannot query the updated content during development, it may be because you did not commit. When changing the content in the table, there is the concept of things. That is, you do not commit ( commit) what you have done, others cannot see your updated content.

How to learn MySQL? Use of update in MySQL and MySQL update

#6. Here is only the operation method of a single table. In the update You can also perform multi-table operations. In the process of making mistakes, you must find the corresponding relationship, otherwise you will have unexpected errors in modifying the data.

How to learn MySQL? Use of update in MySQL and MySQL update

Notes

Nothing can be remembered by just reading an article at the beginning, so while forcing yourself to remember, you can also pay attention to the methods of learning and practicing.

Play while learning, play Middle school. Learning programming is a good way. Gook lunk!!!!

The above is the detailed content of How to learn MySQL? Use of update in MySQL and MySQL update. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn