From: Mario Splivalo <mario.splivalo@mobart.hr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: JOIN query not working as expected
Date: Tue, 06 Dec 2005 16:00:58 +0100
Message-ID: <1133881258.8161.28.camel@ekim> (raw)
In-Reply-To: <164.1133881091@sss.pgh.pa.us>
References: <1133878084.8161.22.camel@ekim>
<164.1133881091@sss.pgh.pa.us>
On Tue, 2005-12-06 at 09:58 -0500, Tom Lane wrote:
> Mario Splivalo <mario.splivalo@mobart.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.splivalo@mobart.hr
"I can do it quick, I can do it cheap, I can do it well. Pick any two."
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mario.splivalo@mobart.hr, tgl@sss.pgh.pa.us
Subject: Re: JOIN query not working as expected
In-Reply-To: <1133881258.8161.28.camel@ekim>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox