It may be an ignored update Statement (update technique) or an update statement
Well, I 've written a simple article again, and I hope you will not be enlightened. This time I want to talk about the update statement in SQL. Speaking of this, there will certainly be a lot of brothers who are not satisfied. Isn't it an update statement? No one will write it. update table set column = expression [where search_condition.
But is the update statement just like this? What is its principle? We use examples to illustrate:
Assume that there is a two-dimensional table with only two fields: Name and score. How can I use an SQL statement to query a student's name, score, and ranking in the table?
Ha ha, this problem is the last time I sent, details see http://www.bkjia.com/article/53832.htm
The result can be viewed there. Now, let's change the question. Assume that this two-dimensional table has three fields: name, score, and ranking. Now, only the names and scores have values. How can we update their rankings?
A friend may come up with a similar solution: first use the query statement to query and then use the cursor to update the ranking.
Is there a better solution? Yes, of course. The answer is to use the update statement.
Update orders table set ranking = (select count (*) + 1 from orders table where a. score <score)
From orders Table
We can see that only one statement is used. At the same time, we can also find that it is different from the update statement we usually write, with more from. In fact, the principle of the update statement is similar to that of the select statement. The complete update statement should be update table set column = expression from table [where search_condition]. it can be seen that the next part is a query statement. When the updated table and the queried table (that is, the table following the from) are completely consistent, we can omit it and write it as our most common update table set column = expression [where search_condition].
The above is just an example to illustrate the use of update. In actual development, flexible and appropriate use of update can achieve twice the result with half the effort.
For UPDATE statements
... I don't know what graphic interface you are using. Press enter to execute the statement, but it is certain that you didn't write it. If the statement cannot be executed, don't tell me that you are the first to write the statement; habits
That's why your worries are mostly worrying... normal people cannot make such ultra-low-level mistakes ..
How to UPDATE multi-row conditions using the UPDATE statement
Where student ID in ('1', '3', '5', '7 ')
You can.