How to get many data at once?

From: 窦德厚(ddh) <doudehou(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to get many data at once?
Date: 2008-08-07 11:03:16
Message-ID: 1181c3540808070403m1118c52bg49c537637d36ae7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christian.Strobl 2008-08-07 11:32:16 Re: looking for psql without server-installation
Previous Message Tomasz Ostrowski 2008-08-07 11:00:44 Re: looking for psql without server-installation