Re: [GENERAL] Using Variables in Queries

Поиск
Список
Период
Сортировка
Искать
От
David G. Johnston
Тема
Re: [GENERAL] Using Variables in Queries
Дата
Msg-id
CAKFQuwbJVx-x16mjym=0KU-3ncs9-=7LfRgC2+v3X35HZswHow@mail.gmail.com
Ответ на
Список
Дерево обсуждения
[GENERAL] Using Variables in Queries "Igal @ Lucee.org" <igal@lucee.org>
Re: [GENERAL] Using Variables in Queries Pavel Stehule <pavel.stehule@gmail.com>
Re: [GENERAL] Using Variables in Queries "David G. Johnston" <david.g.johnston@gmail.com>
Re: [GENERAL] Using Variables in Queries "Igal @ Lucee.org" <igal@lucee.org>
Re: [GENERAL] Using Variables in Queries Tom Lane <tgl@sss.pgh.pa.us>
Re: [GENERAL] Using Variables in Queries "Igal @ Lucee.org" <igal@lucee.org>
Re: [GENERAL] Using Variables in Queries "David G. Johnston" <david.g.johnston@gmail.com>
Re: [GENERAL] Using Variables in Queries Tom Lane <tgl@sss.pgh.pa.us>
Re: [GENERAL] Using Variables in Queries Pavel Stehule <pavel.stehule@gmail.com>
Re: [GENERAL] Using Variables in Queries Scott Mead <scottm@openscg.com>
Re: [GENERAL] Using Variables in Queries Alban Hertroys <haramrae@gmail.com>
On Thu, Oct 19, 2017 at 12:14 PM, Tom Lane <tgl@sss.pgh.pa.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.

В списке pgsql-general по дате отправления
От: Tom Lane
Дата:
От: Tom Lane
Дата:
FAQ