我在單個數據庫中有多個表;從多個表中選擇具有相同列名的數據
UserAccount表; [UserAccount表] [1]
用戶表 [用戶表] [2]
EducationLevels表 EducationLevels table
請注意,這兩個機構和EducationLevels表有相同的名字。
我想查詢數據庫使用;
SELECT
Users.FirstName,
Users.LastName,
UserAccounts.OtherNames,
UserAccounts.Gender,
UserAccounts.DateOfBirth,
Institutions.Name as School,
EducationLevels.Name as Study
FROM
Users, UserAccounts,Institutions
WHERE
UserAccounts.HighestEducationLevelId = EducationLevels.Id
AND
UserAccounts.InstitutionId = Institutions.Id
AND
UserAccounts.UserId = Users.IdUserAccounts
AND
MobileNumber ='*****';
我得到一個錯誤:
Error Code: 1054. Unknown column 'EducationLevels.Name' in 'field
list'
您沒有在您的from子句 –
中包含'EducationLevels',我在您的from子句中沒有看到任何EducationLevels表名。添加這樣的表名*從 用戶,UserAccounts,機構,EducationLevels * – JYoThI