请各位大神帮帮我 ,问题是这样的
首先,一下我的sql语句
select * from customer_info cus join customer_type type on cus.type_id=type.type_id join customer_condition con on cus.condition_id=con.condition_id join customer_source source on cus.source_id=source.source_id join user_info u on u.user_id=cus.user_id where 1=1 and rownum <= 5
minus
select * from customer_info cus join customer_type type on cus.type_id=type.type_id join customer_condition con on cus.condition_id=con.condition_id join customer_source source on cus.source_id=source.source_id join user_info u on u.user_id=cus.user_id where 1=1 and rownum < 1
第一句和最后一句唯一的不同就是最后的where语句那里
其中外键有
以下是一起执行的结果
结果typeId等有外键关联的列的列名变了,请问这是为什么,怎么恢复原来的样子?

oracle数据库中minus和外键问题的求解
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- huangwenkangz 2017-06-26 08:07关注
第二句废话rownum < 1 那只能等于0 所以第二句是没有数据的
select * from customer_info cus join customer_type type on cus.type_id=type.type_id join customer_condition con on cus.condition_id=con.condition_id join customer_source source on cus.source_id=source.source_id join user_info u on u.user_id=cus.user_id where 1=1 and rownum <= 5
改成
select cus.*
from customer_info cus,
customer_type type ,
customer_condition con,
customer_source source,
user_info u
where cus.type_id=type.type_id(+)
and cus.condition_id=con.condition_id(+)
and cus.source_id=source.source_id(+)
and u.user_id(+)=cus.user_id
and rownum <= 5
至于列名变了,感觉这个列名有点像rowid,要先查这个列名是哪里来的本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报