我正在尝试进行分页显示,之前我已经成功使用过这种模式,但是这个模式由于某种原因不起作用:
这有效,
select e.data,e.onorar,d.data,d.suma
from contract_j e
join rata d on e.id_cj = d.id_cj
join persoana l on l.id_p = e.id_avocat
但这不是
select * from (
select a.*, rownum as rnum from (
select e.data,e.onorar,d.data,d.suma
from contract_j e
join rata d on e.id_cj = d.id_cj
join persoana l on l.id_p = e.id_avocat) a
where rownum <= :maxrow)
where rnum >= :minrow
它表示第2行含糊不清的列
为什么呢?我无法理解......
答案 0 :(得分:4)
data
列在SELECT
中2次引用内部查询中的不同表,而在外部查询中它变得模棱两可!因此,只需在内部查询中添加合适的别名即为唯一
select * from (
select a.*, rownum as rnum from (
select e.data as e_data,e.onorar,d.data as d_data,d.suma
from contract_j e
join rata d on e.id_cj = d.id_cj
join persoana l on l.id_p = e.id_avocat) a
where rownum <= :maxrow)
where rnum >= :minrow