释放双眼,带上耳机,听听看~!
数据的高级操作
更新数据
- 基本语法: update + 表名 + set + 字段 = 值 + [where 条件];
- 高级语法: update + 表名 + set + 字段 = 值 + [where 条件] + [limit 更新数量];
执行如下 SQL 语句,进行测试:
1
2
3
4 1-- 将表 my_copy 中的部分 a 更新为 c
2update my_copy set name = 'c' where name = 'a' limit 3;
3
4
执行上述 SQL 语句前:
执行上述 SQL 语句后:
删除数据
与更新类似,可以通过limit来限制删除的数量。
- 基本语法: delete + from + 表名 + [where 条件];
- 高级语法: delete + from + 表名 + [where 条件] + [limit 删除数量];
执行如下 SQL 语句,进行测试