Fight With Me!!!

导航

column 'id' in field list is ambiguous

column 'id' in field list is ambiguous 
这个错误,是因为你查询语句里面有id字段的时候,没有说明是哪个表的id字段,应该加上表名(或者别名)来区分。

用表名进行区分的例子:
select student.id, student.name, score.total
from student, score
where student.id = score.id

使用别名的例子:
用表名进行区分的例子:
select s.id, s.name, c.total
from student s, score c
where s.id = c.id

许多教材都大量使用别名,其实对于初学者,我建议大家看得懂别名就行,自己写的时候用表名好

补充:LEFT函数的参数必须是字段,字段的完成形式是加上表名的,LEFT前面弄个表名就会语法错误的,应该这样:
select left(student.name, 10) .....

posted on 2016-05-28 15:54  nickTimer  阅读(403)  评论(0编辑  收藏  举报