FOR JSON SQL Server 2016 (TABLE to JSON) を使用して JSON オブジェクト内に JSON 配列を作成する方法
ここに私のクエリがあります:
SELECT
m.MeetingId AS tblMeeting_MeetingId,
m.Attended AS tblMeeting_Attended,
m3.CompanyId AS tblMeetingAttendants_CompanyId,
m3.MeetingAttendantsId AS tblMeetingAttendants_AttendantNameWithTitle,
m4.UserId AS tblMeetingAttendees_UserId,
m5.BrokerId AS tblMeetingBroker_BrokerId
FROM Bv.tblMeeting m
LEFT JOIN Bv.tblMeetingAttendants m3 ON m.MeetingId = m3.MeetingId
LEFT JOIN Bv.tblMeetingAttendees m4 ON m.MeetingId = m4.MeetingId
LEFT JOIN Bv.tblMeetingBroker m5 ON m.MeetingId = m5.MeetingId
WHERE m.MeetingId = 739
FOR JSON AUTO, INCLUDE_NULL_VALUES
上記のクエリでは、次のような結果が得られます。
[
{
"tblMeeting_MeetingId": 739,
"tblMeeting_Attended": false,
"tblMeeting_MeetingSubject": " Benchmark China Internet Analyst",
"m3": [
{
"tblMeetingAttendants_CompanyId": 83,
"tblMeetingAttendants_AttendantNameWithTitle": 499,
"m4": [
{
"tblMeetingAttendees_UserId": null,
"m5": [
{
"tblMeetingBroker_BrokerId": 275
}
]
}
]
},
{
"tblMeetingAttendants_CompanyId": 83,
"tblMeetingAttendants_AttendantNameWithTitle": 500,
"m4": [
{
"tblMeetingAttendees_UserId": null,
"m5": [
{
"tblMeetingBroker_BrokerId": 275
}
]
}
]
},
{
"tblMeetingAttendants_CompanyId": 83,
"tblMeetingAttendants_AttendantNameWithTitle": 501,
"m4": [
{
"tblMeetingAttendees_UserId": null,
"m5": [
{
"tblMeetingBroker_BrokerId": 275
}
]
}
]
}
]
}
]
しかし、私はこのような結果が欲しい
[
{
"tblMeeting_MeetingId": 739,
"tblMeeting_Attended": false,
"tblMeeting_MeetingSubject": " Benchmark China Internet Analyst",
"tblMeetingAttendants_AttendantNameWithTitle": [499,500,501],
"tblMeetingAttendees_UserId": null,
"tblMeetingBroker_BrokerId": 275
}
]
できるだけ早く返信してください よろしくお願いし
ます。