silly NULL question - Mailing list pgsql-sql

From Dan Weeks
Subject silly NULL question
Date
Msg-id 16160.26749.931319.656882@underdog.wildbrain.com
Whole thread Raw
Responses Re: silly NULL question
List pgsql-sql
Howdy,

I'm sure most of you PostgreSQL users out there will be able to answer
this, but I'm just not finding the answer.

Let's say I have a table called project that has three fields:

field    |  type
-------------------
id         int
name       varchar(30)
parent_id  int


right now there is only one row in the table:


id   |  name     |   parent_id
-----------------------------------
1    |  silly    |   

You'll notice there is nothing in the parent_id as there is no parent for
this particular project.  Previously (with PostgreSQL 7.1) a query of:

select * from project where name = 'silly' AND parent_id = NULL;

Would return the row.  Now with an upgrade to PostgreSQL 7.3 (yes, I know
there are many changes and we're working through them right now) the same
query returns nothing.  Dropping the "AND parent_id = NULL" returns the row
as expected.

Now, what is the correct specifier for an empty int value?  Or, are there
suggestions for how to create that column (like using NULL as the default
maybe) that experts can clue-stick me with?

Thanks for your time.  If this is the wrong list to ask these questions to
please point me in the right direction.

-dan




pgsql-sql by date:

Previous
From: Greg Stark
Date:
Subject: Re: min() and NaN
Next
From: Rod Taylor
Date:
Subject: Re: silly NULL question