pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Russell Simpkins <russellsimpkins@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Help with multistage query
Date: Wed, 7 Sep 2005 16:05:05 -0400
Message-ID: <BAY103-DAV13C36CCE265B28F7F39B50B5A60@phx.gbl> (raw)
References: <000001c5b3d5$a67a3540$0300a8c0@dell8200>


  I have a perl script that issues a series of SQL statements to perform some queries.  The script works, but I believe there must be a more elegant way to do this.



  The simplified queries look like this:



  SELECT id FROM t1 WHERE condition1;   ;returns about 2k records which are stored in @idarray



  foreach $id (@idarray) {

     SELECT x FROM t2 WHERE id=$id;   ; each select returns about 100 records which are saved in a perl variable

  }

how about 
select t1.id from t1, t2 where t1.id = t2.id and t2.id = x

view thread (4+ messages)  latest in thread

Message-ID: <BAY103-DAV13C36CCE265B28F7F39B50B5A60@phx.gbl>
Permalink:  ../BAY103-DAV13C36CCE265B28F7F39B50B5A60@phx.gbl/
Also on:    postgresql.org/message-id/BAY103-DAV13C36CCE265B28F7F39B50B5A60@phx.gbl

 · 

reply

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: russellsimpkins@hotmail.com
  Subject: Re: Help with multistage query
  In-Reply-To: <BAY103-DAV13C36CCE265B28F7F39B50B5A60@phx.gbl>

* 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