Re: Dates and NULL's`

Поиск
Список
Период
Сортировка
От Emi Lu
Тема Re: Dates and NULL's`
Дата
Msg-id 4DC9A1DD.5070700@encs.concordia.ca
обсуждение исходный текст
Ответ на Re: Dates and NULL's`  (John Fabiani <johnf@jfcomputer.com>)
Список pgsql-sql
>>> Where mydate>= "2011/04/01"::date and mydate<= "2011/04/30"::date
>>> With the above where will the NULL's be selected????
>>
>> Here is what I get when I try:
>>
>> spi=>  SELECT NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE;
>>   ?column?
>> ----------
>>
>> (1 row)
>>
>>
>> spi=>  SELECT (NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE) IS TRUE;
>>   ?column?
>> ----------
>>   f
>> (1 row)
>>
>>
>> spi=>  SELECT (NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE) IS FALSE;
>>   ?column?
>> ----------
>>   f
>> (1 row)
>>
>>
>> spi=>  SELECT (NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE) IS UNKNOWN;
>>   ?column?
>> ----------
>>   t
>> (1 row)
> Sorry Richard, I do not understand.
>
> It looks like you are saying the NULLS will be returned too

As a summary:
============================================
(1)
null:date COMPARE 'real date'::DATE
Will always return NUll, so you will not get the record returned at all!

(2) examples he provided:

. (null:date COMPARE 'real date'::DATE) IS NULL;
. (null:date COMPARE 'real date'::DATE) IS UNKNOWN;

Null returns true.

(3) null is true/false;    returns false

Emi





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

Предыдущее
От: Brent Dombrowski
Дата:
Сообщение: Re: Dates and NULL's`
Следующее
От: Theodore Petrosky
Дата:
Сообщение: Re: Dates and NULL's`