oracle修改语句,怎么修改最后一条记录的字段!
updateptb_yjf_jcbSetQMYE="&zHJYE&"whereZHBH='"&ZHBH&"'andQMYE="&YHYE&满足这个条件的记录有两条或者多条...
update ptb_yjf_jcb Set QMYE = " & zHJYE & " where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE & 满足这个条件的记录有两条或者多条,我怎么修改最后一条记录里的QMYE这个字段的值啊!
展开
3个回答
展开全部
--假设这个表的主键是id, order by 是按什么排序
update ptb_yjf_jcb Set QMYE = " & zHJYE & " where id=(select id from (select id,row_number() over (order by id desc) as rn from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE & ") where rn=1)
update ptb_yjf_jcb Set QMYE = " & zHJYE & " where id=(select id from (select id,row_number() over (order by id desc) as rn from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE & ") where rn=1)
追问
我表里没有唯一的标识字段应该怎么办哦!
展开全部
update ptb_yjf_jcb Set QMYE = & zHJYE & ' where ZHBH = ' & ZHBH & 'and QMYE = ' & YHYE &'
and rownum=(select max(rownum) from ptb_yjf_jcb where ZHBH = ' & ZHBH & 'and QMYE = ' & YHYE &' )
and rownum=(select max(rownum) from ptb_yjf_jcb where ZHBH = ' & ZHBH & 'and QMYE = ' & YHYE &' )
追问
好像不行,一行都不能被更改!如果把MAX修改为MIN倒是可以改第一行!
展开全部
update ptb_yjf_jcb Set QMYE = " & zHJYE & " where ZHBH =
(
select * from ptb_yjf_jcb
where rownum<(select count(*)+1 from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE )
minus
select * from ptb_yjf_jcb
where rownum<(select count(*) from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE )
)
(
select * from ptb_yjf_jcb
where rownum<(select count(*)+1 from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE )
minus
select * from ptb_yjf_jcb
where rownum<(select count(*) from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE )
)
更多追问追答
追问
你这样怎么会报值过多的错误呢!
追答
select * from ptb_yjf_jcb
where rownum<(select count(*)+1 from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE )
minus
select * from ptb_yjf_jcb
where rownum<(select count(*) from ptb_yjf_jcb where ZHBH = '" & ZHBH & "' and QMYE = " & YHYE )
最后一条记录的查出记录了吗?
来自:求助得到的回答
本回答被提问者采纳
1
已赞过
已踩过<
评论
举报
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询