1、sql更新:
UPDATE NUM_ACTIVE_INTEGRAL_ a SET
status_=0
WHERE EXISTS(
--条件为:已处理的主表记录中,有明细记录,并且明细记录的状态值为7或者为null,而且主表记录的创建时间在指定范围内
SELECT 1 FROM NUM_ACTIVE_INTEGRAL_DET_ b
WHERE b.info_id_=a.id_
AND a.status_=999
AND a.create_date_>=20080601 AND a.create_date_<20080701
AND (b.status_=7 OR b.status_ IS NULL)
)
update code2 set name=(select name from code1 where code1.code=code2.code)
2、 视图更新
update (select code1.name n1,code2.name n2 from code1 c1,code2 c2 where c1.code=c2.code) set n2=n1