3

我有一个数据库,我正在执行一个查询:

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);
4

1 回答 1

3

您可能引入了一个错字……您可能想要:

select * from 
Exams LEFT OUTER JOIN Test on Test.tExamID = Exams.eID       
LEFT OUTER JOIN Users on Users.userID = Test.tUserID
于 2013-07-11T13:42:45.453 回答