使用前面博客中的例子
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;
2、查询sno但是不加表名
select sno,sname,sgender,sbirthday,sadd,math,english
from student inner join score on student.sno = score.sno;
3、查询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;
5、在3、的基础上加上表名student(或score)
select sname,student.sno,sgender,sbirthday,sadd,math,english
from student inner join score on student.sno = score.sno;
所以,共同字段的应该指定表名,不然软件无法知道是哪个表的,
在进一步也就是有“歧义”的字段指明了表名别的可以不指定。