Re: SQL questiom

Поиск
Список
Период
Сортировка
От Jacob Bunk Nielsen
Тема Re: SQL questiom
Дата
Msg-id 87v8ydwa0z.fsf@localhost
обсуждение исходный текст
Ответ на SQL questiom  (hamann.w@t-online.de)
Список pgsql-general
hamann.w@t-online.de writes:

> I am using a query pretty often that looks like
> SELECT <<fixed columns from tables>> WHERE <<fixed join statements>> AND
> <<actual select criterion>>
>
> Is there a way (with sql or plpgsql)  to convert that into
> SELECT myquery('<<actual select criterion>>')

I would solve that by creating a view like:

CREATE VIEW some_view_name AS 
  SELECT <<fixed columns from tables>> WHERE <<fixed join statements>>;

See also https://www.postgresql.org/docs/14/sql-createview.html

Then you can query that view with your actual select criterion like:

SELECT * FROM some_view_name WHERE <<actual select criterion>>;

Best regards,
Jacob




В списке pgsql-general по дате отправления:

Предыдущее
От: Duarte Carreira
Дата:
Сообщение: Re: Query on postgres_fdw extension
Следующее
От: Matthias Apitz
Дата:
Сообщение: recording of INDEX creation in tables