This article is mysql database Question 1 Import the data from Table 1 into Table 2: Import the data from Table 1 into Table 2: Insert the data in Table 2 into Table 1. The columns in Table 1 correspond to the columns selected in Table 2. INSERT INTO table1 (column1, column2, column3, column4) select column1, column2, column3, column4 from table 2 When inserting data into the table in question 2, a field takes the maximum value of the field in the database and adds 1. When inserting data into a table, a field takes the maximum value of the field in the database and adds 1. Many people say that this problem can be solved by using stored procedures or something. In fact, the combination of insert and select can solve this problem very well. Example: When inserting a new record into table 1, the age value is the maximum value in the database and added 1, and is stored in the database as the age of the new data. (Of course, the select statement for age can also add a where condition.) INSERT INTO table1( column1, column2, column3, column4, age )SELECT column1, column2, column3, column4, (select IFNULL((select max(age) from table name,0)+1); Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Docker deployment springboot project example analysis
>>: How to use webSocket to update real-time weather in Vue
Method 1: Submit via the submit button <!DOCTY...
Table of contents Achieve results Implementation ...
MySQL master-slave configuration and principle, f...
A common development need is that we want to coll...
Preface This article mainly shares with you the g...
1. Overview The so-called life cycle function is ...
Copy code The code is as follows: <form method...
<br />A contradiction arises. In small works...
Table of contents Preface Example summary Preface...
environment: 1. Windows Server 2016 Datacenter 64...
This article mainly describes two kinds of underl...
Table of contents uni-app Introduction HTML part ...
Table of contents Overview Defining filters Use o...
Table of contents 1. Introduce cases 2. View the ...
Table of contents Preface Connection Management A...