MySQL inserts data, mysql inserts data
INSERT data
- Insert complete rows
- Insert Part of a row
- Insert multiple rows
- Insert query results
Insert the complete row and check the original customer list first:
INSERT a row: insert into customersVALUES (NULL, 'pep E. laPew ', '2014 Main Street', 'Los Angeles ', 'CA', '000000', 'USA', NULL, NULL );
Another way is to specify the column name. In this way, when the table structure changes, its SQL statement can still be used, and this assignment does not need to be the same as the original table structure.
INSERT multiple rows you can combine multiple INSERT statements:
INSERT... VALUES (,,,,);
INSERT... VALUES (,); in this way, you can INSERT two records. If the column names to be inserted are the same, you can merge the INSERT statements as follows:
Insert into name (,) // the same column name values (,) will be used for subsequent inserts of multiple records (,,,,,,,,,), (.........), (.........); // In this way, three records are inserted.
Insert the retrieved data is to use the SELECT statement to retrieve the data and insert it into the table as the value of VALUES. The following SQL statement combines the custnew table into the customer table:
Insert into MERs (cust_id, cust_contact, cust_email, cust_name, cust_address, region, cust_state, region) SELECT cust_id, cust_contact, upper, cust_name, cust_address, lower, cust_state, lower, cust_countryFROM custnew;
Insert mysql Data
Enter
Mysql-u root-p and press enter to prompt you to enter the password
This prompt will appear after you enter mysql after entering the password.
Mysql-> enter the database where your test table is located. -- Do not forget the seal.
Then execute insert into test (a, B, c) VALUES (, 3)
The premise is that your test table contains column a, column B, and column c.
Insert a value of 1, 2, 3 for column a B and column c.
Of course you can.
Insert test (a, B, c) select 1, 2, 3
How to add data to the mysql table
How can this problem be solved? Pay attention to the consistency between the data type added and the table creation.
Example:
// Create a table
Create table tab_nam (
Age int,
Name char (10)
)
// Insert data
Insert into tab_nam (age, name) values (11, 'aaa ')
Insert into tab_nam (age, name) values (22, 'bbb ')
......