What is a update statement
This article mainly explains "what is the update sentence". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the update sentence"?
This time we are going to talk about the update statement in sql. At this point, there must be a lot of brothers dissatisfied, isn't it the update sentence? Who can't write, update table set column=expression [where search_condition].
But is the real update statement just like that? What is the essence of it? what is its principle? Let's use an example to illustrate:
Suppose you have a score sheet with only two fields, name and grade. How to use a sql statement to find out a student's name, score and ranking in the table?
Hehe, this question was posted by me last time. For details, please see https://www.jb51.net/article/53832.htm.
As a result, you can go there to watch. Now change the problem, suppose that this score table has three fields, name, score and ranking, now only the name and score are worth, how to update their ranking?
Some friends may propose a similar solution: first query it out with a query statement, and then update the ranking through cursors.
Is there a better solution? Of course there is, and the answer is to use the update statement.
Update score table set rank = (select count (*) + 1 from grade table where a. Achievement