I would like to select data from 2 tables into one json string. First table should list all linked tables from second table like
First table:
SELECT [orderNumber], [tcpState]
FROM [Tracking]
Second table:
SELECT [startdate], [enddate], [tcpState], [orderNumber], [name]
FROM [Stations]
Tracking can link several stations.
Expected result:
[{
"orderNumber": 123455,
"tcpState": 3,
"Stations": [{
"startdate": "2011-05-06",
"enddate": "2012-09-15",
"tcpState": 3,
"name": "Roger"
},
{
"startdate": "2011-02-06",
"enddate": "2012-05-15",
"tcpState": 4,
"name": "Hans"
}
]
},
{
"orderNumber": 1566,
"tcpState": 3,
"Stations": [{
"startdate": "2011-06-06",
"enddate": "2012-08-15",
"tcpState": "6",
"name": "Mike"
},
{
"startdate": "2011-03-06",
"enddate": "2012-03-15",
"tcpState": "6",
"name": "Tom"
}
]
}
]