Re: Question about WHERE CASE

Поиск
Список
Период
Сортировка
От Martin Stöcker
Тема Re: Question about WHERE CASE
Дата
Msg-id da8bed3e-b178-a788-075e-93c3cbfb8b88@stb-datenservice.de
обсуждение исходный текст
Ответ на Question about WHERE CASE  (Mike Martin <redtux1@gmail.com>)
Список pgsql-sql

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

case when ('yes'= lower($1)) then (phone_number is not null)      when ('no'=lower($1)) then (phone_number is null)      else true 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
Вложения

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

Предыдущее
От: Mike Martin
Дата:
Сообщение: Question about WHERE CASE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Question about WHERE CASE