From: Dan Wilson <phpPgAdmin@acucore.com>
To: herbie@nextearth.com
To: pgsql-php <pgsql-php@postgresql.org>
Subject: Re: Rows in tables...
Date: Mon, 19 Feb 2001 14:50:47 -0800
Message-ID: <02c001c09ac6$6790d140$078353d8@danwilson> (raw)
References: <3A9192B7.EF0D1A2B@nextearth.com>
You may be looking for a query like this:
SELECT * FROM [table] ORDER BY random() LIMIT 1
This will automtically select a random row and only return 1 tuple. This
will cut down on your query time and the memory usage.
I don't know if that was what you are trying to do.
-Dan
> What is the easiest way to get the total number of
> rows in a table? I want to do a random pick from a
> table and need to know how many rows are in the
> table.
>
> Do I do a "SELECT * FROM table" and use the info
> from this, or will a select return all the data?
> This is where I'm hazy. Or does fetch_row actually
> return the data?
>
> Any help is appreciated,
> Herbie Pabst
>
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: phpPgAdmin@acucore.com, herbie@nextearth.com
Subject: Re: Rows in tables...
In-Reply-To: <02c001c09ac6$6790d140$078353d8@danwilson>
References: <3A9192B7.EF0D1A2B@nextearth.com> <02c001c09ac6$6790d140$078353d8@danwilson>
* 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