I need some guidance on joins
Hi I am using joins because it makes the most sense in my application, I was gonna try out the relations api but I want to work on my sql skills as well, so I have this schema and I am trying to understand how to get all teh tables returned in a single query
here is the schema
I stripped all the extra columns so there might be a syntax error in there, sorry in advance
What I am trying to get is something like this
And of course all the other fields
So far I have this query which at least in typescript looks ok (my db is not set up so I can't test at the moment) but I don't know how to get the nested tables
I probably need another left join but where do I put that?
5 Replies
on a side note I see that the results are not gonna be in the shape that I want it, it's an internal tool so minor inconvenience but how could I change that?
preferably without a performance hit, I don't want to loop over potentially thousands of rows within js
no way of doinng that, thats how sql works, its just a row, youu will have to do a reduce or map after that
Relational queries – DrizzleORM
Drizzle ORM | %s
Does this add additional queries?
the doc doesn't specified that, but it seems that is oonly a layer on top of the oooriginal lib, so it should
you could add a logger on your db and see it for yourself