mysql关联更新update
来源:互联网 发布:女儿出嫁父亲知乎 编辑:程序博客网 时间:2024/06/06 07:29
样式1:
样式2:
突然发现mysql的一些sql语法也很神奇,像这样式的sql语句,在oracle中是行不通的,需要其他的形式。
另外的几个例子:
update xcs_user_credit_score a1,xcs_user_credit_score a2 set a1.user_currday_score=a1.user_currday_increment_score+a2.user_currday_score where a1.pt_day='2017-09-20' and a2.pt_day='2017-09-19' and a1.uid=a2.uid;
样式2:
update xcs_user_credit_score a1 inner join xcs_user_credit_score a2 on a1.uid=a2.uid set a1.user_currday_score=a1.user_currday_increment_score+a2.user_currday_score where a1.pt_day='2017-09-20' and a2.pt_day='2017-09-19';
突然发现mysql的一些sql语法也很神奇,像这样式的sql语句,在oracle中是行不通的,需要其他的形式。
另外的几个例子:
--sub:update xcs_user_credit_score a1,xcs_user_credit_score a2 set a1.user_currday_score=(case when a2.user_currday_score-10>0 then a2.user_currday_score-10 else 0 end) where a1.pt_day='2017-09-20' and a2.pt_day='2017-09-19' and a1.uid=a2.uid and (a1.seqing_score=0 and a1.user_silent_score=0 and a1.jubao_score=0 and a1.chengpaopao_score=0 and a1.weifan_score=0 and a1.upper_manage_score=0 and a1.pay_active_score=0 and a1.view_active_score=0 and a1.message_active_score=0 and a1.gift_active_score=0 and a1.live_active_score=0) and a2.user_currday_score>0;--plus:update xcs_user_credit_score a1,xcs_user_credit_score a2 set a1.user_currday_score=(case when a1.user_currday_score+10<0 then a1.user_currday_score+10 else 0 end) where a1.pt_day='2017-09-20' and a2.pt_day='2017-09-19' and a1.uid=a2.uid and (a1.seqing_score=0 and a1.user_silent_score=0 and a1.jubao_score=0 and a1.chengpaopao_score=0 and a1.weifan_score=0) and a1.user_currday_score<0;
阅读全文
0 0
- mysql关联更新update
- 【SQL】update关联更新
- mysql update 关联
- mysql update 两个表关联{两个关联表如何更新其中一个表的数据}
- mysql 更新数据 update
- mysql update from 关联更新 从一个表字段 到另外一个表字段
- 使用update更新关联的表
- oracle UPDATE 多表关联更新
- 多表关联更新,UPDATE FROM用法
- SQL update 多表关联更新
- Oracle 多表关联更新update
- UPDATE与多表关联更新
- oracle update set select from 关联更新
- update left join 多表关联更新,
- Oracle Update多表关联更新
- Oracle如何在update中多表关联更新
- SQL update 多表关联更新
- Oracle多表关联更新(update多表关联)
- docker基础及第一个helloworld
- 用于精准判断的贝叶斯定理
- Spring安全框架Shiro
- 用JS获取地址栏参数的方法
- CSS Shapes实现元素滚动自动环绕
- mysql关联更新update
- python numpy教程
- elasticsearch数据导出/导入
- NopiHelper Excel导出 导入
- excel中如何在一个单元格中输入多行文字
- cocos2dx+KinectV2 体感游戏之微信打飞机
- 面向对象的设计原则
- spring的@Transactional注解详细用法
- 负载均衡----实现配置篇(Nginx)