agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Martin Stöcker <martin.stoecker@stb-datenservice.de>
To: pgsql-sql@lists.postgresql.org
Subject: Re: Question about WHERE CASE
Date: Thu, 5 Sep 2019 13:42:57 +0200
Message-ID: <da8bed3e-b178-a788-075e-93c3cbfb8b88@stb-datenservice.de> (raw)
In-Reply-To: <CAOwYNKYVz67+qK6QfSiJVhCA8fAXzpHLS-L9HG=SEhOUzJ0A1w@mail.gmail.com>
References: <CAOwYNKYVz67+qK6QfSiJVhCA8fAXzpHLS-L9HG=SEhOUzJ0A1w@mail.gmail.com>
Hi,
where requires a boolean expression, for instance
select * from stuff where true;
Hence "CASE WHEN $1=dir THEN TRUE ELSE metadir=$1 END" returns a boolean
value everything is fine.
Regards martin
Am 05.09.2019 um 13:04 schrieb Mike Martin:
> I have come across the following construct which works in postgres
>
> WHERE CASE WHEN $1=dir THEN TRUE ELSE metadir=$1 END
>
> via
> (https://stackoverflow.com/questions/49859153/filter-with-yes-no-and-all-in-postgres)
> |casewhen('yes'=lower($1))then(phone_number
> isnotnull)when('no'=lower($1))then(phone_number isnull)elsetrue end |
> |I was always under the impression that a case expression could only
> be on the right side of a where expression ie: |
> |WHERE fieldname=<cse expression> |
> |Is this a postgres extention, cant find any documentation on this |
> |thanks |
> |Mike |
--
Widdersdorfer Str. 415, 50933 Köln; Tel. +49 / 221 / 9544 010
HRB Köln HRB 75439, Geschäftsführer: Dr. Dirk Goldner, ppa. Melanie Lillich
Attachments:
[image/jpeg] icapbifdkakidkdn.jpg (13.6K, ../da8bed3e-b178-a788-075e-93c3cbfb8b88@stb-datenservice.de/3-icapbifdkakidkdn.jpg)
download | view image
view thread (3+ messages) latest in thread
Message-ID: <da8bed3e-b178-a788-075e-93c3cbfb8b88@stb-datenservice.de>
Permalink: ../da8bed3e-b178-a788-075e-93c3cbfb8b88@stb-datenservice.de/
Also on: postgresql.org/message-id/da8bed3e-b178-a788-075e-93c3cbfb8b88@stb-datenservice.de
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: martin.stoecker@stb-datenservice.de, pgsql-sql@lists.postgresql.org
Subject: Re: Question about WHERE CASE
In-Reply-To: <da8bed3e-b178-a788-075e-93c3cbfb8b88@stb-datenservice.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox