Skip to Content.
Sympa Menu

freetds - Re: select with NULL in where-clause doesnt work

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Bob Kline <bkline AT rksystems.com>
  • To: TDS Development Group <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: select with NULL in where-clause doesnt work
  • Date: Fri, 11 Oct 2002 16:54:20 -0400 (EDT)


On Fri, 11 Oct 2002, Hans Lang wrote:

> Hi,
>
> i am using freetds 0.60 with php 4.2.3 on Intel-Linux P4, 1.8Ghz.
> The SQL-Server is a MS SQL 7.0 Server, running on an PIII, 1Ghz.
>
> the problem i have is that i can't select records that have a NULL
> in a DATETIME-field.

Yes, you can, you're just not using correct SQL.

>
> For example the value of "ausgeschieden", which is a DATETIME, in the
> record with ID=315 :
>
> 1> select ausgeschieden from personal_adresse where id=315
> 2> go
> ausgeschieden
> NULL
>
> this is fine, ID 315 isnt "ausgeschieden" yet.
>
> Looking up for that record results in an empty set:
> 1> select id from personal_adresse where ausgeschieden=NULL
> 2> go
>
> This is mysterious. Where is at least ID=315?

...

> so what the hell is wrong with those NULLs here?

No need to get upset. Try the following corrected version of your
query:

SELECT id
FROM personal_adresse
WHERE ausgeschieden IS NULL

> running the same selects with the sybase-libs does work. no wonder,
> they are obviously right.

Just because Sybase is doing what you think it should do, doesn't make
it "obviously right."

Pick up a good book on SQL and read about why you can't compare an
unknown value with another unknown value and determine whether those two
values equal each other.

> what can i do to make them run with freetds as well?

Doesn't have anything to do with freetds. It's how the SQL standard is
written.

--
Bob Kline
mailto:bkline AT rksystems.com
http://www.rksystems.com







Archive powered by MHonArc 2.6.24.

Top of Page