Re:CTEs as Lookup Tables
by reactivenz on Wednesday January 11, 2023 @08:23PM
(#34347799)
those UNION's should be UNION ALL otherwise they are deduplicated. Thus you code is worse, also the VALUES express is nicer when done in longer form
you can often alias the VALUES values like:
and some DB's allow you to alias via the cte name:
[ Parent
| on HN ]
Re:CTEs as Lookup Tables
by acjohnson55 on Wednesday January 11, 2023 @10:35PM
(#34348862)
In the last example, it seems like it would be nice for the DB to let you omit the `SELECT * FROM` part.