我有以下表格:
A(StudentID, Name, Years)
B(Age, LibraryID)
C(Years, Grade, LibraryID)
这是我的代码中给我带来麻烦的一部分:
c1 cursor for select LibraryID, Age, Grade, Name from A,B,C where b.LibraryID = c.LibraryID and c.Years=a.Years;
我收到以下错误:
column reference "LibraryID" is ambiguous
答案 0 :(得分:2)
确实有一个含糊不清的名字。您的查询中有两个LibraryID
字段:一个来自表B
,另一个来自表C
。您只需指定要选择字段的表格,例如:
c1 cursor for select B.LibraryID, Age, Grade, Name
from A,B,C where B.LibraryID = C.LibraryID and C.Years=A.Years;
您在LibraryID
子句中的from
字段上加入这些表的事实并不能使它们与select
子句相等