1.获取job表中多条记录中的最新的一条记录
/*Dialect*/select a.*
from job a
where not exists(select 1
from job b
where b.deptcode=a.deptcode and b.stime>a.stime)
and a.ismaster=1 and a.deptcode in ('DP0205','DP41','DP5600')
order by stime desc;
2、执行job表中最新表的状态值,可重新同步数据
update job set synstatus=0 where id in (select a.id
from job a
where not exists(select 1
from job b
where b.deptcode=a.deptcode and b.stime>a.stime)
and a.ismaster=1 and a.deptcode in ('DP0205','DP41','DP5600'))
博客给出了job表的两条SQL操作。一是查询job表中指定部门代码、主记录下各部门的最新记录;二是更新这些最新记录的状态值为0,可用于重新同步数据,体现了数据库操作中查询与更新的应用。

被折叠的 条评论
为什么被折叠?



