Pascal Tufenkji wrote:
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join
> sip_demissionaire d on d.emp_id = c.emp_id where c.emp_id = 342 ;
[snip - rows]
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join
> sip_demissionaire d on d.emp_id = c.emp_id where c.institution = 1;
[snip - rows]
> 
> BUT IF I PUT BOTH CONDITIONS
> 
>  
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join
> sip_demissionaire d on d.emp_id = c.emp_id where c.emp_id = 342 and
> c.institution = 1;
[snip - no rows]

> What's the problem ?
> 
> I'm sure that the problem is with the view "sip_demissionaire" cause when I
> copied its content to a temp table, the query returned a result.

> SELECT * into temp foo from sip_demissionaire ;
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join foo
> d on d.emp_id = c.emp_id where c.emp_id = 342 and c.institution = 1;

Good testing. It looks to me like you have a corrupted index. If you run
EXPLAIN ANALYSE SELECT ... for each of your queries, you'll probably see
that the one that returns no rows is using a particular index that the
other queries aren't.

Have you had any crashes / power failures / disk errors recently?

Oh - and what version of PostgreSQL is this?

-- 
  Richard Huxton
  Archonet Ltd

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to