如何显示我没有得到'an expression of non-boolean type specified in a context where a condition is expected'的


SELECT   CoachFirst AS 'First Name', CoachLast AS 'Last Name', CoachCity AS 'City', TeamName AS 'Team'
FROM     tblCoaches A,
tblTeams B
WHERE    A.CoachID = B.TeamCoach
AND      CoachCity = 'Bowmanville' AND 'Whitby';

每次执行代码时,我都会收到错误

我想你打算IN

SELECT c.CoachFirst AS FirstName, c.CoachLast AS LastName, c.CoachCity AS City,
t.TeamName AS Team
FROM tblCoaches c JOIN
tblTeams t
ON c.CoachID = t.TeamCoach 
WHERE t.CoachCity IN ('Bowmanville', 'Whitby');

请注意我所做的其他更改:

  • 使用正确、明确、标准JOIN语法。切勿FROM子句中使用逗号。
  • 使用有意义的表别名,而不是任意的。
  • 限定所有列引用,以便了解它们的来源。
  • 不要对列别名使用单引号。 实际上,只需使用不需要转义字符的别名即可。

相关内容

  • 没有找到相关文章

最新更新