Say I'm doing something simple like selecting everything from two tables:
"SELECT * FROM table1; SELECT * FROM table2;"
It will return a results object that looks like:
{rows:[{},{},{} etc...]}
Where the array of row objects is every row from table1
, followed by every row from table2
.
What I want is to be able to combine the above SELECT
statements into one DB query but have it return something like:
[
{table1rows:[{},{},{}]}
,{table2rows:[{},{},{}]}
]
...so that I can avoid multiple queries of the DB while then fudging each query's results object into a custom object I reference from DB query to DB query like a caveman. So one query, one clean results set I can handle on the client knowing which array of rows came from which table.
Can you use AS
for this? How would I achieve this with one query?