| From: | Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> |
|---|---|
| To: | "Diehl, Jeffrey" <jdiehl(at)sandia(dot)gov> |
| Cc: | pgsql-sql(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Help with query. (*) |
| Date: | 2001-01-18 14:57:32 |
| Message-ID: | 20010118145732.F29761@quartz.newn.cam.ac.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-sql |
On Tue, Jan 16, 2001 at 01:42:45PM -0700, Diehl, Jeffrey wrote:
> I'm having difficulty writing a query which I really can't live without...
>
> I need to get a list of records from table A for which there are
> corresponding records in table B. I've tried to use the intersect clause,
> but it doesn't seem to work, or it runs far too long. For example:
>
> select * from A
> where 1=1
> intersect select * from A where
> B.x=A.x
> and A.y=B.y
> and A.z=B.z
> limit 100
>
> I need the most efficient method possible; my A tables have upward of 5
> Million records. The B table, btw, only has about 100 records.
Guessing - my system isn't in a state to test just at the minute - is it
select A.* from A,B
where A.x=B.x
and A.y=B.y
and A.z=B.z
limit 100
that you want?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martin A. Marques | 2001-01-18 15:06:29 | compilation error |
| Previous Message | Gregory Wood | 2001-01-18 14:56:30 | Re: Query question |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | guard | 2001-01-18 15:00:40 | Distributed database ? |
| Previous Message | Yury Don | 2001-01-18 12:11:29 | Re: python+postgresql |