How to get many data at once? - Mailing list pgsql-general

From 窦德厚(ddh)
Subject How to get many data at once?
Date
Msg-id 1181c3540808070403m1118c52bg49c537637d36ae7@mail.gmail.com
Whole thread Raw
Responses Re: How to get many data at once?  (Bill Moran <wmoran@collaborativefusion.com>)
Re: How to get many data at once?  ("Chandra ASGI Tech" <chandraasgi@gmail.com>)
List pgsql-general
Hi, if I have such a table:

t_ref_id     t_data
--------------------
1             'abc'
2             '321'
1             'ddd'
2             'xyz'
9             '777'
...


I want to get data with a special t_ref_id:

SELECT t_data FROM THETABLE WHERE t_ref_id = '1';

I must use a while loop to extract the data (I'm using PHP):

$rows = array();
while (($row = pgsql_fetch_assoc($result) !== false) {
    $rows[] = $row;
}

And if there are many matched rows, such as many hundreds or thousands of rows, I think such a loop maybe inefficient.

How to do this in a more efficient way?

Thank you!



--
ddh

pgsql-general by date:

Previous
From: "ramamurthy kv"
Date:
Subject: Need info on installer
Next
From: sagswe
Date:
Subject: compiling Xpath functions in PostgreSQL 8.3.3