我的查询如下......
select *
from UserMaster um
inner join ForumMaster fm on um.UserID = fm.UserID
left join
(select * from CommentMaster cm) cmt on cmt.TopicID = @TopicID
我的表格如下......
UserMaster
(UserID, FName, LName
)CommentMaster
(CommentID, TopicID, Comment
)ForumMaster
(TopicID, UserID, Topic, DateCreated
)我希望上面三张表中的数据具有相同的TopicID
...
答案 0 :(得分:0)
select *
from UserMaster um
left outer join ForumMaster fm on um.UserID = fm.UserID
left outer join CommentMaster cm on cm.TopicId = fm.TopicId
where
cm.TopicId = @TopicId
答案 1 :(得分:0)
试试这个
SELECT * FROM UserMaster um, CommentMaster cm, ForumMaster fm WHERE fm.UserID = um.UserID AND fm.TopicID = cm.TopicID
我在不使用join命令的情况下加入表。