2 回答

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊
update a set classroom=1
from student_dept a join tblkpi b on b.deptid=a.id
where (b.ks1 is not null or b.ks1>0) and (b.ks2 is not null or b.ks2>0)
and a.classroom=0 and b.year=YEAR(GETDATE()) and b.month=MONTH(GETDATE())
-- ms sql

TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個(gè)贊
declare @sr1 int ,@ks2 int
select @sr1=sr1 ,@ks2=ks2 from tblkpi nolock where 條件 --如果沒有條件的話,需要用到游標(biāo)
if(@sr1 is null or @ks2 > 0)
修改student_dept中的classroom=1where classroom=0 并且tblkpi中的deptid=student_dept的id 而且當(dāng)前系統(tǒng)時(shí)間的年份等于tblkpi中的year字段值,月份等于month字段值~~
- 2 回答
- 0 關(guān)注
- 683 瀏覽
添加回答
舉報(bào)