Subject Re: how NULL compares
Author Svein Erling Tysvær
Hello!

If my guess is correct, you only fill in one of the fields for each
record. If so, the only problem you have is that you use AND where you
should use OR. I would rewrite your query as

SELECT *
WHERE (TIMEIN > :Param1 AND TIMEIN < :Param2) OR
(TIMEOUT > :Param1 AND TIMEOUT < :Param2)

Alternatively, you could restructure the table like:

ID INTEGER
TIMEREGISTERED TIME
TIMETYPE CHAR(1)

and populate the records:

1 Time1 I
2 Time2 O
3 Time3 I
4 Time4 O

HTH,
Set

--- In firebird-support@yahoogroups.com, "d_dude_2003" wrote:
> Hi there guys,
>
> I have a table like
>
> ID INTEGER
> TIMEIN TIME
> TIMEOUT TIME
>
> populates with records like
> 1 Time1 <Null>
> 2 <Null> Time2
> 3 Time3 <Null>
> 4 <Null> Time4 etc.
>
> If i use
>
> SELECT *
> WHERE (TIMEIN > Param1) AND (TIMEIN < Param2) AND (TIMEOUT > Param1)
> AND (TIMEOUT < Param2)
>
> will it return the right records and NULL is not being compared
> here?
>
> Hope u get it :)
>
> Thanx alot,
> Eugene.