我需要在SQL(Oracle)中使用相同的set
值但不同where
值更新大约500条记录。我想作为一个语句而不是500个不同的语句执行。任何帮助表示赞赏。以下是我的更新声明示例。
update proddta.f564211
set sd$prdcflg = ''
where sd$prcflg = 'Y'
AND sddoco = 86615
and sddcto = 'S1'
and sdlnid = 1.000
update proddta.f564211
set sd$prdcflg = ''
where sd$prcflg = 'Y'
AND sddoco = 86615
and sddcto = 'S1'
and sdlnid = 2.100
update proddta.f564211
set sd$prdcflg = ''
where sd$prcflg = 'Y'
AND sddoco = 86618
and sddcto = 'S1'
and sdlnid = 1.000
update proddta.f564211
set sd$prdcflg = ''
where sd$prcflg = 'Y'
AND sddoco = 86618
and sddcto = 'S1'
and sdlnid = 2.100
答案 0 :(得分:1)
这个怎么样:
update proddta.f564211
set sd$prdcflg = null
where sd$prcflg = 'Y'
and sddcto = 'S1'
and ( sddoco, sdlnid ) in
( (86615, 1.000)
, (86615, 2.100)
, (86618, 1.000)
, (86618, 2.100) );