In ordinary projects, I often encounter this problem: I need to update and query data in one bid at the same time. For example, if there is a table of data as shown below, the update operation now needs to be: update the name value of status=1 to the name value of id=2 Usually we think of the following statement to achieve this requirement: However This completes the operation in the question. The general process is: query the data of id=2 as the intermediate table t; query the set data from the t table; perform the update operation so that you do not update and select the same table in the same statement, because this is equivalent to operating two tables, tb_test and the intermediate table t. The final result is as follows: You may also be interested in:
|
<<: Encapsulate a simplest ErrorBoundary component to handle react exceptions
>>: How to count the number of specific characters in a file in Linux
Library Operations Query 1.SHOW DATABASE; ----Que...
Data cleaning (ETL) Before running the core busin...
First create a specific project directory for you...
On some websites, you can often see some pictures...
What is Fuser Command? The fuser command is a ver...
MySQL will automatically create a database named ...
Table of contents 1. parse 1.1 Rules for intercep...
The virtual machine is installed on the host mach...
background When we talk about transactions, every...
Preface The following are the ways to implement L...
1. Performance schema: Introduction In MySQL 5.7,...
Many organizations have the need to back up file ...
Sometimes it is necessary to perform simple verif...
Here is a brief introduction to indexes: The purp...
1. Form <form id="" name=""...