请各位大神帮帮我 ,问题是这样的
首先,一下我的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,要先查这个列名是哪里来的本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条
- ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
- ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
- ¥15 perl MISA分析p3_in脚本出错
- ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
- ¥15 ubuntu虚拟机打包apk错误
- ¥199 rust编程架构设计的方案 有偿
- ¥15 回答4f系统的像差计算