How to combine queries from 2 tables?

I feel dumb asking this question...
So I have 2 queries which looks like this:
// guranteed to have 1 entry
const result1 = await db.select().from(Table1).where(condition1);
// can have many entries
const result2 = await db.select().from(Table2).where(condition2);
const finalResult = { result1, result2 };

The 2 tables don't have a relationship with each other.
I want to optimize this to make it a single query to obtain finalResult
  • Should I use a db.transaction? I'm not sure if a transaction helps as transactions are useful for write operations .
  • Is there any other way or am I just overthinking?
Was this page helpful?