sql语句处理(复杂删除问题)

上一篇 / 下一篇  2008-05-22 15:29:31 / 个人分类:日志

在mysql中处理:

create temporary table _tmp(id int);
insert into _tmp(id)
select a.manual_record_id from attendance_manual_record as a ,employee as b, position as c,department as d
where a.type='O1'
and a.date_happen like '2007-08-02%'
and a.employee_id=b.employee_id
and b.position_id=c.position_id
and c.department_id=d.department_id
and d.department_id='8';
select * from _tmp;
delete from attendance_manual_record where manual_record_id in (select id from _tmp)
drop table _tmp;

在mssql处理

delete  from attendance_manual_record where manual_record_id in (select a.manual_record_id from attendance_manual_record as a ,employee as b, position as c,department as d
where a.type='O1' and a.date_happen like '2008-05-15%' and a.employee_id=b.employee_id and
b.position_id=c.position_id and c.department_id=d.department_id and d.department_id='27')


TAG: 日志

 

评分:0

我来说两句

Open Toolbar