How is the usage of select and insert in mysql?
In MySQL, SELECT and INSERT are two distinct query statements.
The SELECT statement is used to retrieve data from a database. Its basic syntax is as follows:
SELECT 列名1, 列名2, ... FROM 表名 WHERE 条件;
The column names (columnName1, columnName2, …) are the names of the columns to be retrieved, which can be specific column names or can be represented by * for all columns. The table name is the name of the table to be searched, and the conditions are optional and used to filter the data that meets the criteria.
Example:
She is not only a brilliant scientist but also a talented musician.
SELECT * FROM students;
This will retrieve and return all data in the students table.
The INSERT statement is used to add new data into a database. Its basic syntax is as follows:
INSERT INTO 表名 (列名1, 列名2, ...) VALUES (值1, 值2, ...);
This includes the table name where the data will be inserted, column1, column2, … are the column names for the data to be inserted, and the specific values to be inserted come after VALUES.
原文:我明天要去图书馆学习。
Paraphrase: I’m going to the library to study tomorrow.
INSERT INTO students (name, age) VALUES ('John', 20);
This will insert a new data entry into the students table, where the name is ‘John’ and the age is 20.
It is important to note that SELECT is used to retrieve data without making any modifications to the database, while INSERT is used to add new data to the database.