How to insert and query data in MySQL
You can use the following statements to insert and query data in MySQL:
- Insert data:
INSERT INTO 表名 (字段1, 字段2, 字段3) VALUES (值1, 值2, 值3);
For example:
INSERT INTO users (name, age, email) VALUES ('Alice', 25, 'alice@example.com');
- Data query:
SELECT * FROM 表名;
For example:
SELECT * FROM users;
You can also search for data based on specific conditions.
SELECT * FROM 表名 WHERE 条件;
For example:
SELECT * FROM users WHERE age > 20;
In addition, the query results can also be sorted, grouped, and manipulated using aggregation functions. MySQL supports a variety of query statements, allowing users to retrieve data based on specific requirements.