select rn,id from
(select rownum rn,id,name from id<'1' order by id desc)
where rn=1
union all
select id,name from id='1'
union all
select id,name from id>'1' where rownum=1
(select rownum rn,id,name from id<'1' order by id desc)
where rn=1
union all
select id,name from id='1'
union all
select id,name from id>'1' where rownum=1
这条语句不用rowid我觉得是不可能做出来的
不难嘛
select * from (
(select * from tbl_name where id= :id)
union
select * from (select * from tbl_name where id< :id order by id desc) where ROWNUM=1
union
select * from (select * from tbl_name where id> :id order by id asc) where ROWNUM=1
)
select id,lag(id,1,null) over(order by id) as last_record,lead(id,1,null) over(order by id) as next_record from table;
to Samland(samland) : 偶们写的是一回事:)
select * from tbname
where id between (id-1) and (id+1)括号可以不要
or id in
(select max(id) from tbname where id <:id)
or id in
(select min(id) from tbname where id>:id)
or
((id in
(select max(id) from tbname where id <:id)
or id in
(select min(id) from tbname where id>:id)) and id is not null)
这个long是什么意思?vc的long还是oracle的long?