3 ms·
Composing in this context means that one part of your application (eg the list controller) builds part of a query (the select from) and another part (eg the fil
by laszlokorte 7y ago
Composing in this context means that one part of your application (eg the list controller) builds part of a query (the select from) and another part (eg the filter controller) builds another part of the query (the where part) and yet another part of you application (the paginator) alters there where part, adds limits and offset and build another query based on the same filter conditions to calculate the total row count. All that without the different controllers knowing each others in advance. This is not possible without complicated string manipulation or building some not-sql-query-algebra.
Some api like prepared statements (supported by the db itself) for building up complex queries step by step would be nice. Does something like this exist?
- ratww 7y agoSQL queries can be composed like in your example if you use subqueries.
- deleted 7y ago[deleted]
- bjoli 7y agoAs the other answer to you says: subqueries will do that. DBs automagically unnesting subqueries has been a thing for a long time, so usually you won't get any performance impact (With a big warning for correlated subqueries).