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
Preface Every good habit is a treasure. This arti...
MySQL deduplication methods 【Beginner】There are v...
Preface JavaScript is not like other languages ...
Table of contents Parent component communicates w...
1. Native network request 1. XMLHttpRequest (w3c ...
1. Problem description The storage installed in t...
The execution efficiency of MySQL database has a ...
Table of contents cause: go through: 1. Construct...
Copy code The code is as follows: <object id=&...
Although Mac systems come with PHP and Apache, so...
In daily work, we sometimes run slow queries to r...
The sudo command allows a trusted user to run a p...
Take MySQL 5.7.19 installation as an example, fir...
Table of contents 1. Download the system image fi...
Some time ago, I needed to use pip downloads freq...