zoukankan      html  css  js  c++  java
  • sql 修改

    修改

    1.单表修改

    updateset 字段1='123',字段2='helloword'
    updateset 字段1='123',字段2='helloword' where id=1 
    updateset 字段1=字段2,字段2='helloword' where id=1

    解析:update和set 是此语法的关键字,where和查询的where一致用于筛选数据,多个字段更新用逗号(,)隔开,也可以将另一字段的值更新到此字段直接写字段名就行。

    2.多表修改

    update 表1 set 字段1=b.字段2,b.字段2=a.字段2 from 表1 a,表2 b where a.id=b.id and a.id=1
    
    update 表1 set 字段1=(select 字段1对应字段 from 表2 b where 表1.id=b.id ) where  a.id=1

    解析:update和set   from 是此语法的关键字,多表语法在于多个表逗号分隔( 表1 a,表2 b)通过得到where a.id=b.id 条件进行关联表1和表2,where 条件后面也可以带其他条件

    PS:语法有好几种每个数据库支持的语法不一样请大家具体尝试

  • 相关阅读:
    bzoj2751
    bzoj1483
    bzoj1011
    bzoj1412
    bzoj1820
    bzoj1295
    bzoj3444
    Java--Exchanger用于进行线程间的数据交换
    Java--Semaphore控制并发线程数量
    Java--Spring AOP 源码散点记录(最后整理成一篇博客)
  • 原文地址:https://www.cnblogs.com/YorkQi/p/14801644.html
Copyright © 2011-2022 走看看