SQL批量更新数据库
来源:互联网 发布:js获取select选中的值 编辑:程序博客网 时间:2024/05/16 05:00
筛选本表的记录,更新符合要求的数据
-- 修改根据表中字段记录的到达时间是否是48小时后的订单,如果是,则批量更新
update OrderBase set
OrderState = 8
from (select * from dbo.OrderBase where 3 = datediff(DD,EndTime,getdate()) and OrderState <> '6' and OrderState <> '7' and OrderState <> '8' and OrderState <> '9' ) as 筛选后的数据表 inner join OrderBase on 筛选后的数据表.Order_Id = OrderBase.Order_Id
-- 3 表示从次日起,48小时后订单过期
-- 修改时,当订单状态为已经完成或正常过期或用户取消或企业取消 时,不修改订单状态
-- 将 订单状态改为 8 用户过期
update OrderBase set
OrderState = 8
from (select * from dbo.OrderBase where 3 = datediff(DD,EndTime,getdate()) and OrderState <> '6' and OrderState <> '7' and OrderState <> '8' and OrderState <> '9' ) as 筛选后的数据表 inner join OrderBase on 筛选后的数据表.Order_Id = OrderBase.Order_Id
-- 3 表示从次日起,48小时后订单过期
-- 修改时,当订单状态为已经完成或正常过期或用户取消或企业取消 时,不修改订单状态
-- 将 订单状态改为 8 用户过期
其实上面这个SQL语句就简直就是脱什么放什么
update OrderBase set
OrderState = 8
where 1 = datediff(DD,EndTime,getdate()) and OrderState <> '6' and OrderState <> '7' and OrderState <> '8' and OrderState <> '9'
OrderState = 8
where 1 = datediff(DD,EndTime,getdate()) and OrderState <> '6' and OrderState <> '7' and OrderState <> '8' and OrderState <> '9'
原来上学的时候做过这类的题,只不过忘记了,现在回顾一下
关键字: from 一般都用where
from 后接表名与需更新表的关系
- SQL批量更新数据库
- Sql Server根据记录集批量更新数据库
- Android数据库更新,批量执行大量的sql脚本
- 批量更新数据库数据(SQL update select语句)
- 【数据库SQL】批量更新促发器游标的方法
- 批量更新sql 语句
- SQL 批量更新语句
- 批量更新 sql
- sql批量更新
- SQL批量更新
- Sql server 批量更新
- 数据库批量更新
- PHP批量更新数据库
- 数据库批量更新(TVP)
- Oracle数据库批量更新
- java批量更新数据库
- Mybatis批量更新数据库
- sqlbulkcopy 批量更新 数据库
- 编程意识
- 每日一句2006-12-30
- Basic :“青春长驻”还是“菜鸟陷阱”----------转自北理金老师
- 教你如何使用Google进行搜索
- 相关打印问题
- SQL批量更新数据库
- 子窗口控件
- 如何安装CISCO路由
- 具有I2C总线接口的A/D芯片PCF8591及其应用
- 每日一句2006-12-31
- BT下载 BitComet
- 每日一句2007-01-01
- bbPress中文版
- ...find the size of a file?