How to insert data into a table in MySQL?
You can use the INSERT INTO statement to insert data into a table in MySQL.
The grammar is as follows:
Here is the grammar:
INSERT INTO 表名 (列1, 列2, 列3, ...) VALUES (值1, 值2, 值3, ...);
The specific steps are as follows:
- Connect to the MySQL database server.
- Choose the database where the data will be inserted.
- Insert data using the INSERT INTO statement. Provide values to be inserted in the VALUES clause in the order of the table columns.
Suppose there is a table named “students” with columns “id”, “name”, and “age”, and we need to insert a record into the table with id 1, name “John”, and age 20.
INSERT INTO students (id, name, age) VALUES (1, 'John', 20);
After executing the statement above, the data will be inserted into the “students” table.