From: | Julien Cigar <jcigar(at)ulb(dot)ac(dot)be> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | ALL() question |
Date: | 2007-11-14 13:39:02 |
Message-ID: | 1195047542.3190.9.camel@frodon.be-bif.ulb.ac.be |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello,
I have a problem with the ALL() subquery expression.
I have three tables:
- specimens
- test_bits
- specimen_test_bits
The specimen_test_bits table contains two foreign keys, one to
specimens(id), another to test_bits(id).
Here is an output of specimen_test_bits:
muridae=> select * from specimen_test_bits;
specimen_id | test_bit_id
-------------+-------------
46096 | 1
46096 | 2
46096 | 3
46096 | 4
52894 | 1
52894 | 3
12546 | 2
What I would like is a query that returns all the specimen_id of
this table which have _all_ the given test_bit_id. So in this
case, with test_bit_id 1,2,3,4 it should return only
specimen_id 46096.
With the following I got a syntax error:
select specimen_id
from specimen_test_bits
where test_bit_id = all(1,2,3,4);
The following works but no rows are returned :
select specimen_id
from specimen_test_bits
where test_bit_id = all(select id from test_bits where id in (1,2,3,4));
Any idea how I could do this ? I guess the problem is my ALL() expression ...
In advance thanks,
Julien
From | Date | Subject | |
---|---|---|---|
Next Message | Philippe Lang | 2007-11-14 13:47:56 | Re: Temporal databases |
Previous Message | hubert depesz lubaczewski | 2007-11-14 13:31:16 | Re: ALL() question |