column ambiguously defined &oracle数据库分页语句查询中select嵌套时出错
select * from(select doublefaceinform.*,company.*,rownum trid from doublefaceinform,company where doublefaceinform.comid=company.comid and rownum <=8)where trid >5;
里边没错,嵌套外边也没错。但是这是多表查询
多表操作时,语句中的列名,不明确。
全部写成 表|表别名.字段 可避免
即:
select temp_book.* from(select doublefaceinform.douid,doublefaceinform.pushDate,company.comName,company.companyNum,company.registerBureau,company.registerDate,rownum trid from doublefaceinform,company where doublefaceinform.comid=company.comid and rownum <=8)temp_book;
转载于 lev草梦的博客
【1】: http://blog.sina.com.cn/s/blog_141718efb0102xly9.html
我的补充理解
SELECT * from(
select A.*, ROWNUM RN FROM(
select c.*,b.*, from student b join(
select id,name,sex,size from user_code
) c on b.id = c.id
)A WHERE ROUNUM <= 6
) ```WHERE RN >3
这种情况也会出现 ORA-00918: column ambiguously defined,只要把 c.*
或者 b.*
的具体字段写出来也行
SELECT * from(
select A.*, ROWNUM RN FROM(
select b.*, c.id,c.name,c.sex from student b join(
select id,name,sex,size from user_code
) c on b.id = c.id
)A WHERE ROUNUM <= 6
) ```WHERE RN >3