Re: JOIN query not working as expected

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

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.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mario Splivalo 2005-12-06 15:00:58 Re: JOIN query not working as expected
Previous Message Michael Burke 2005-12-06 14:55:12 Re: Database with "override" tables