Re: JOIN query not working as expected

From: Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: JOIN query not working as expected
Date: 2005-12-06 15:00:58
Message-ID: 1133881258.8161.28.camel@ekim
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 2005-12-06 at 09:58 -0500, Tom Lane wrote:
> Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> writes:
> > Now I want all services which didn't have any messages within certain
> > period:
> > pulitzer2=# select * from services where id not in (select distinct
> > service_id from messages where receiving_time between '2005-10-01' and
> > '2005-10-30');
> > (0 rows)
>
> > Why is that?
>
> Probably, you've got some NULLs in the messages.service_id column ...
> try excluding those from the sub-select.

Yes, I've discovered that later. Still, I'm confused with the 'biggies'
at the bottom of my initial mail.

I neglected to metion that I'm using postgresql 7.4.8. I discovered that
I can create a FK on a column wich allows NULL values, and I can even
insert rows with NULLs in FK column, although PK table where FK is
pointing does not allow nuls. Is that 'by design', or...?

Mike
--
Mario Splivalo
Mob-Art
mario(dot)splivalo(at)mobart(dot)hr

"I can do it quick, I can do it cheap, I can do it well. Pick any two."

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-12-06 15:02:31 Re: JOIN query not working as expected
Previous Message Tom Lane 2005-12-06 14:58:11 Re: JOIN query not working as expected