我有一个数据库,我正在执行一个查询:
select * from
Exams LEFT OUTER JOIN Test on Test.tExamID = Exams.eID
LEFT OUTER JOIN Test on Users.userID = Test.tUserID
但是我收到了错误ambiguous column name main.Test.tID
。你以前见过吗?请帮我弄清楚发生了什么。
我的数据库如下:
CREATE TABLE [Exams] (
[eID] INTEGER NOT NULL PRIMARY KEY,
[eType] INTEGER NOT NULL,
[eLevel] INTEGER NOT NULL,
[eTime] INTEGER,
[eNote] CHAR);
CREATE TABLE [Users] (
[userID] TEXT NOT NULL,
[userPassword] TEXT NOT NULL);
CREATE UNIQUE INDEX [userID] ON [Users] ([userID]);
CREATE TABLE [Test] (
[tID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[tUserID] TEXT NOT NULL REFERENCES [Users]([userID]),
[tExamID] INTEGER NOT NULL REFERENCES [Exams]([eID]),
[tDate] DATE NOT NULL,
[tScore] INTEGER NOT NULL,
[tNote] CHAR NOT NULL);
答案 0 :(得分:3)
你可能引入了一个错字......你可能想要:
select * from
Exams LEFT OUTER JOIN Test on Test.tExamID = Exams.eID
LEFT OUTER JOIN Users on Users.userID = Test.tUserID