开发者

Why isnt this SQL command working

SELECT info, date
FROM Professor, Professor_Comment,开发者_运维知识库 Comment
WHERE pID = ?
AND Professor_Comment.pcID = Professor.pcID
AND Comment.commID = Professor_Comment.commID;
;

Why isnt this SQL command working


That's likely to be because the pID is ambigious and the Professor doesn't have a pcID.

Try this:

SELECT info, date
FROM Professor_Comment, Comment
WHERE pID = ?
AND Comment.commID = Professor_Comment.commID;

However, I prefer the explicit JOIN syntax:

SELECT info, date
FROM Professor_Comment
JOIN Comment ON Comment.commID = Professor_Comment.commID
WHERE pID = ?;


  1. You have pID = ?, but pID is ambiguous because it appears in Professor and Professor_Comment

    Change that sole pID to either Professor.pID or Professor_Comment.pID

  2. You have Professor_Comment.pcID = Professor.pcID, the Professor table has it listed as dID, not pcID

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜