I'm using inner join to join 3 tables, Owner, Store and Machine. I'm trying to view output JSON from multiple tables like this:
SELECT ow.*, st.*, ma.*
FROM owner ow
INNER JOIN st.store ON ow.OwnerId = st.OwnerId
INNER JOIN machine ma ON ma.StoreId = st.StoreId;
I want JSON formatted like this:
{
"OwnerId": "1d2dd",
"Name": "name test",
"Store":[{
"StoreId": "s3ss5",
"Name": "Store1",
"Code": "bla",
"Machine":[{
"MachineId": "axpeo",
"Name": "Machine1",
"Type": "type1"
}]
},
{
"StoreId": "ddf22",
"Name": "Store2",
"Code": "ble",
"Machine":[{
"MachineId": "weds",
"Name": "Machine2",
"Type": "type2"
},
{
"MachineId": "axdso",
"Name": "Machine3",
"Type": "type3"
}]
}]
}
but the return JSON is not formatted like this I'm using PostgreSQL.