Mysql database —— Insert data into a table

one , Insert tuple

database :own ->> surface :fruit

->>> Data insertion syntax :
insert into Table name ( Listing 1, Listing 2, Listing 3,...) values( Column value 1, Column value 2, Column value 3,...)
remarks : The column value needs to correspond to the column name one by one

Example 1 :( Insert all data )
# The column name corresponds to the value one by one , The order can be inconsistent with the order in the table insert into fruit(id,name,price,num)
values(1," Banana ",3.11,10);

Example 2 :( Insert partial data )【 Choose according to the columns you need , Most commonly used 】
insert into fruit(name,num) values(" Apple ",10);

Example 3 :( Omit column name to insert data )【 Insert data for all columns by default 】
# Must be 4 Values , One to one correspondence with columns insert into fruit values(3," a mandarin orange ",null,20);

Pay attention :

(1) Non empty columns must be given data

(2) Autoincrement column may not insert data

two , Insert subquery results

->>> Data insertion syntax :
insert into Table name Subquery results
Example 1 :
insert into fruit select * from fruits where price>10;

Example 2 :
insert into fruit(name,num) select name, num from fruits;


©2020 ioDraw All rights reserved
python gui Interface examples -Python GUI Programming complete example IO flow —— Classification of flow ,InputStream,OutputStream,Reader,Writer etc. Thread.setDaemon Set up the Daemons STM32 RS485 modbus Communication source program , The test is effective stay MATLAB 2018 Time series prediction with deep learning vue3 Write component library and publish to npm The process of Questions and answers for the interviewer : How did you get a project in the project team ??? In the applet form Multiple cycles input How to get each input Value of 2021 Front end high frequency interview questions ( You have to watch it !!!)js Array method