Re: [GENERAL] Coditional join of query using PostgreSQL

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: [GENERAL] Coditional join of query using PostgreSQL
Дата
Msg-id 57AF6AB9-3064-4702-A775-29EC4E0926ED@gmail.com
обсуждение исходный текст
Ответ на [GENERAL] Coditional join of query using PostgreSQL  (Nick Dro <postgresql@walla.co.il>)
Список pgsql-general
> On 15 May 2017, at 19:02, Nick Dro <postgresql@walla.co.il> wrote:
>
> Hi,
> I'm new to postgresql and couldn't find answer to this situation anywhere.
> I asked this here:
> http://stackoverflow.com/questions/43984208/coditional-join-of-query-using-postgresql
>
> I hope there is a better solution rather than creating two separated functions :(

You can use your boolean parameter inside the join condition:
[…] on (tfquery.a = main.a and ((type_f and tfquery.d = main.d) or not type_f))

Beware that you don't also have a column named type_f in that join somewhere.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



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

Предыдущее
От: Dmitry Dolgov
Дата:
Сообщение: Re: [GENERAL] Insert performance and disk usage in JSON vs JSONB
Следующее
От: Ken Tanzer
Дата:
Сообщение: [GENERAL] Help: Installing 9.6 breaks local connections to 9.2 on Centos 6.9