From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Igal (at) Lucee(dot)org" <igal(at)lucee(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Using Variables in Queries |
Date: | 2017-10-19 19:20:43 |
Message-ID: | CAKFQuwbJVx-x16mjym=0KU-3ncs9-=7LfRgC2+v3X35HZswHow@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Oct 19, 2017 at 12:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> FROM products,
> (values ('red widget'::text)) consts(target)
> WHERE similarity(target, item_name) > 0.25
> ORDER BY target <<-> item_name
>
> PG 9.5 and up will flatten out cases like this to be exactly what you
> wrote out longhand.
>
Does it matter if the values expression is embedded in a CTE? I find the
construct:
WITH constants AS ( VALUES (,,) )
SELECT * FROM tbl CROSS JOIN constants
nice as it keeps the constants at the top of the query string. I presume
pure style differences between using multiple from items and an explicit
cross join.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-10-19 19:35:49 | Re: Using Variables in Queries |
Previous Message | Tom Lane | 2017-10-19 19:14:26 | Re: Using Variables in Queries |