Here is a simplified version of the problem I'm trying to solve:
Table A with id and some data:
id, data
A01, xxxx
A02, xxxx
...
Table B with id and some other kind of data
id, data
B01, xxxx
B02, xxxx
...
Table Events with data that looks like this:
timestamp, event_type, object_id
xxxxxxxxx, A_something, A01
xxxxxxxxx, B_thing, B01
xxxxxxxxx, A_this, A02
xxxxxxxxx, A_that, A03
etc...
I have a query that retrieves events, using a timestamp range, and then I need to get the data from the different tables into arrays.
Events:
xxxxxxxxx, A_something, A01
xxxxxxxxx, B_thing, B01
xxxxxxxxx, A_this, A02
would need to fetch:
- A01 from table A
- B01 from table B
- A02 from table A
and then make an array of arrays out of it:
[
[ columns from A01 ],
[ columns from B01 ],
[ columns from A02 ]
]
The output can also be a json string.
And I have absolutely no clue how this can be done.
Any pointers would be greatly appreciated.