Hannu Krosing <hannu@tm.ee> writes:
> SELECT x.*
> FROM x,
> (select match (x.foo, '([0-9]+)x([0-9]+)')
> from x innerx
> where innerx.pk = x.pk
> ) as res
> HAVING y = get_match_group(res, 2)
> OR y = get_match_group(res, 3)
> ;
Well you don't need to go fetch from the table an extra time. Presumably the
data will be cached but it's still a lot of extra work to process the data
twice.
You could just do
select * from ( select x.*, (select match(foo, '([0-9]+)x([0-9]+)') as res )where y = res[2]
or y = res[3]
But what Hannu's saying is that the SQL Standard WITH is precisely syntactic
sugar for subqueries used like above.
It sounds like WITH is to subqueries as let is to lambda....
--
greg