MySQL基础-11 DML语言-修改

DML语言-修改

1 **语法

  1. 修改单表记录
    update table_name
    ser column1=value1,column2=value2,…
    where 筛选条件
    **
  2. 修改多表的记录
    sql92语法:
    update table_name1 别名,table_name2 别名
    set 列=值 ,…
    where 连接条件
    and 筛选条件;

    sql99语法:
    update table_name1 别名,
    inner|left|right join table_name2 别名
    on 连接条件
    set 列=值 ,…
    where 筛选条件

2 案例

  1. 修改beauty表中姓唐的女神的电话为13888888899
update beauty
set phone='13888888899'
where name like '唐%';
  1. 修改多表记录
    修改张无忌的女朋友的手机号为114
update boys bo
inner join beauty b on bo.id=b.boyfriend.id
set b.phone='114'
where bo.boyName='张无忌';
  1. 修改没有男朋友的女神的男朋友的编号为2号
update boys bo
right join beauty b on bo.id=b.boyfriend.id
set b.boyfriend_id=2
where bo.id is null;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值