On Fri, Oct 21, 2022 at 9:50 AM abhijit <m...@abhij.it> wrote:

> Hi,
>
> I have multiple dataset queries. What would be the best way to create a
> union in this scenario?
>
> I have tried -
>
> ds1.union(ds2.union(ds3.union)))
>
> as well as
>
> ds1.union(ds2).union(ds3)
>
> In either case, the resulting SQL looks unnecessarily nested, although the
> results are identical.
>
> Is there a better way?
>

You probably want:

ds1.union(ds2, from_self: false).union(ds3, from_self: false)

By default, unions are wrapped in a subselect so that filtering and other
changes on the resulting dataset works as expected.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSeyBSNNHoss%3Dg%2BPLHS5YRDEj5tL3q%2B0yVZcMi1zGBXsJQ%40mail.gmail.com.

Reply via email to