初学oracle--共有字段表名能不能省略

使用前面博客中的例子
http://blog.csdn.net/m0_37949689/article/details/79217183
student和score都有字段sno,下面的测试只是使用内连接inner join查询两张表
1、不查询字段sno

select sname,sgender,sbirthday,sadd,math,english 
from student inner join score on student.sno = score.sno;

不含sno
不含sno

2、查询sno但是不加表名

select sno,sname,sgender,sbirthday,sadd,math,english 
from student inner join score on student.sno = score.sno;

含sno不含表名
3、查询sno不加表名并且将sno放到查询的第二个字段(换位置)
sno换位置

select sname,sno,sgender,sbirthday,sadd,math,english 
from student inner join score on student.sno = score.sno;

4、在2、的基础上加上表名student(或score)

select student.sno,sname,sgender,sbirthday,sadd,math,english 
from student inner join score on student.sno = score.sno;

加入表名student
5、在3、的基础上加上表名student(或score)

select sname,student.sno,sgender,sbirthday,sadd,math,english 
from student inner join score on student.sno = score.sno;

sno调换位置后加入表名student


所以,共同字段的应该指定表名,不然软件无法知道是哪个表的,
在进一步也就是有“歧义”的字段指明了表名别的可以不指定。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值