oralce分页报错 select p.*,c.* ,rownum r
from (select * from tj_star where manager_id =0 ) p,tj_user c
where c.user_id = p.user_id;
这个没有问题
select * from(
select p.*,c.* ,rownum r
from (select * from tj_star where manager_id =0 ) p,tj_user c
where c.user_id = p.user_id)
where r>4 and r<8;加上分页就报错
错误;ORA-00918: 未明确定义列
00918. 00000 - "column ambiguously defined"
*Cause:
*Action:
行 7 列 8 出错
我给select p.*,c.* ,rownum r
from (select * from tj_star where manager_id =0 ) p,tj_user c
where c.user_id = p.user_id;加上别名依然不行 ------解决方案--------------------
SELECT *
FROM (SELECT P.*, C.*, ROWNUM R
FROM (SELECT * FROM TJ_STAR WHERE MANAGER_ID = 0) P, TJ_USER C
WHERE C.USER_ID = P.USER_ID
AND ROWNUM < 8)
WHERE R > 4;
------解决方案-------------------- select p.*,c.* ,rownum r
p和C两张表的字段定义列出来看一下,应该是有重名的。
字段定义在dba_tab_columns里头。
简单点来说是这样。
select column_name,count(*) from
dba_tab_columns t
where t.table_name in ('name of table p','name of table c')
group by column_name
having count(*) >1