Re: Help with multistage query

Поиск
Список
Период
Сортировка
От Matt Emmerton
Тема Re: Help with multistage query
Дата
Msg-id 003001c5b3f4$6a6911b0$1200a8c0@gsicomp.on.ca
обсуждение исходный текст
Ответ на Help with multistage query  ("Rick Schumeyer" <rschumeyer@ieee.org>)
Ответы Re: Help with multistage query  ("Jim C. Nasby" <jnasby@pervasive.com>)
Список pgsql-sql
 
----- Original Message -----
Sent: Wednesday, September 07, 2005 4:05 PM
Subject: Re: [SQL] Help with multistage query
 

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
 
or more correctly, based on the OP's example:
 
select t2.x from t1, t2 where t1.id = t2.id and t1.id = <condition>
 
--
Matt

В списке pgsql-sql по дате отправления:

Предыдущее
От: Philip Hallstrom
Дата:
Сообщение: Re: column names, types, properties for a table
Следующее
От: "DownLoad X"
Дата:
Сообщение: Re: Searching for results with an unknown amount of data