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
Editor's note: This article is contributed by...
1. Download from the official website and unzip h...
In HTML pages, visual elements such as buttons an...
Copy code The code is as follows: <html> &l...
1. px px is the abbreviation of pixel, a relative...
1. Command Introduction The ipcs command is used ...
Table of contents Preface What does yarn create d...
Problem Description In the login page of the proj...
Table of contents 1. Shopping cart example 2. Cod...
This article shares the specific code of Javascri...
Table of contents 1. Introduction 2. Introduction...
The most common way is to set a primary key or un...
This article mainly introduces three methods of i...
The effect of completing a menu bar through displ...
Online shopping mall database-user information da...