在用oracle时出现了很怪的情况,举个例子,我不分页查询时候sql 为
select fm.freight_gid,cf.city_name, ct.city_name
from freight_mst fm
left join CITY cf on cf.city_index=fm.from_city
left join CITY ct on ct.city_index=fm.to_city
查询可以,但是我加分页后
select * from (select a.*,ROWNUM rn from (
select fm.freight_gid,cf.city_name, ct.city_name
from freight_mst fm
left join CITY cf on cf.city_index=fm.from_city
left join CITY ct on ct.city_index=fm.to_city
) a where ROWNUM<=8) where rn>0
在a.*就出现了ora-00918,未明确定义列,
若是删除一个city 表的连接,又可以执行查询
select * from (select a.*,ROWNUM rn from (
select fm.freight_gid,cf.city_name
from freight_mst fm
left join CITY cf on cf.city_index=fm.from_city
) a where ROWNUM<=8) where rn>0
我猜问题可能是a.*和一张表的两次定义起冲突了,但是该如何解决呢?
已经困了一天了,实在不行才来请教大神们
------解决思路----------------------
select * from (select a.*,ROWNUM rn from ( select fm.freight_gid,cf.city_name, ct.city_name city_name1 from freight_mst fm left join CITY cf on cf.city_index=fm.from_city left join CITY ct on ct.city_index=fm.to_city ) a where ROWNUM<=8) where rn>0
里面加别名区分还不行么?