我的目标是获得以下查询结果:
"Discussion": {
"DiscussionID": 1,
"Name": "Some Name",
"Body": "Some Body",
"Comments": [
{
"CommentID": 1,
"Body: "Some Body
}
]
}
我有2个表:讨论和评论。讨论有很多评论
Discussion Table:
=================
DiscussionID
Name
Body
Comments Table:
===============
CommentID
DiscussionID
Body
如何获得讨论的所有评论并获取讨论列?
答案 0 :(得分:0)
这适用于两个表的连接。
尝试这样的事情:
SELECT *
FROM Discussion D
JOIN Comments C
ON C.DiscussionID = D.DiscussionID