MySQL 8 update语句更新数据表里边的数据

数据重新补充

这里使用alter table Bookbought.bookuser add userage INT after userphone;为用户表bookuseruserphone列后边添加一个类型为INT的新列userage
使用alter table Bookbought.bookuser add sex varchar(6) after userage ;为用户表bookuseruserage 列后边添加一个类型为INT的新列sex
在这里插入图片描述

describe Bookbought.bookuser;查看数据库中的表结构,可以查看插入之后的数据字段。
在这里插入图片描述

update更新数据

使用格式如下:

update 数据库.表名 
set 字段 = 字段值  
where 判断条件

使用下方的update语句把以前没有填上去的年龄填上去。

update Bookbought.bookuser set userage = 31,sex='male' where id = 1;
update Bookbought.bookuser set userage = 32,sex='female' where id = 2;
update Bookbought.bookuser set userage = 33,sex='male' where id = 3;
update Bookbought.bookuser set userage = 34,sex='female' where id = 4;
update Bookbought.bookuser set userage = 35,sex='male' where id = 5;
update Bookbought.bookuser set userage = 36,sex='male' where id = 6;
update Bookbought.bookuser set userage = 37,sex='female' where id = 7;
update Bookbought.bookuser set userage = 38,sex='male' where id = 8;
update Bookbought.bookuser set userage = 45,sex='male' where id = 9;
update Bookbought.bookuser set userage = 50,sex='female' where id = 10;

在这里插入图片描述

相关推荐

  1. MySQL数据库——10、UPDATE 更新

    2023-12-06 06:48:04       37 阅读
  2. mysql update set时使用and连接使更新数据出现问题

    2023-12-06 06:48:04       39 阅读
  3. (vue)怎么监听表单数据

    2023-12-06 06:48:04       64 阅读
  4. 数据库||数据表更新

    2023-12-06 06:48:04       49 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-06 06:48:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-06 06:48:04       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-06 06:48:04       82 阅读
  4. Python语言-面向对象

    2023-12-06 06:48:04       91 阅读

热门阅读

  1. el-from表单实现lable字体大小改变

    2023-12-06 06:48:04       51 阅读
  2. Unix Network Programming Episode 82

    2023-12-06 06:48:04       57 阅读
  3. Unix Network Programming Episode 83

    2023-12-06 06:48:04       59 阅读
  4. 西南科技大学C++程序设计实验四(类与对象三)

    2023-12-06 06:48:04       59 阅读
  5. 透明度值和注意点

    2023-12-06 06:48:04       45 阅读
  6. 编程思想/oop设计模式

    2023-12-06 06:48:04       54 阅读
  7. Android Studio的代码笔记--IntentService学习

    2023-12-06 06:48:04       61 阅读
  8. .Net Core 单元测试获取配置文件节点值

    2023-12-06 06:48:04       40 阅读