Home  >  Article  >  Database  >  mysql add, delete, modify and query statements

mysql add, delete, modify and query statements

下次还敢
下次还敢Original
2024-05-08 10:57:541103browse

mysql增删改查语句怎么写?这是不少网友都关注的问题,接下来由PHP小编为大家带来mysql增删改查语句例子,感兴趣的网友一起随小编来瞧瞧吧!

mysql add, delete, modify and query statements

mysql增删改查语句例子

1、增加记录在 MySQL 中,我们可以使用 INSERT INTO 语句添加一条新的记录。示例:INSERT INTO students(name, age, gender) values('Tom', 23, 'male');这个语句将会向 students 表中插入一条名为 Tom,年龄为 23,性别为男性的记录。

2、删除记录通常使用 DELETE FROM 语句,语法如下:DELETE FROM students WHERE id = 3;这条语句将会从 students 表中删除指定 id 的学生记录。

3、修改记录通常使用 UPDATE 语句,语法如下:UPDATE students SET age = 24 WHERE name = 'Tom';这条语句将会更改名为 Tom 的学生的年龄为 24。

4、查询记录通常使用 SELECT 语句,语法如下:SELECT * FROM students;这条语句将会查询 students 表中的所有记录。我们也可以根据条件查询指定的记录,例如:SELECT * FROM students WHERE age > 20;这条语句将会查询所有年龄大于 20 岁的学生记录。

The above is the detailed content of mysql add, delete, modify and query statements. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn