pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Rows in tables...
4+ messages / 4 participants
[nested] [flat]

* Rows in tables...
@ 2001-02-19 21:40 Herb Pabst <herbie@nextearth.com>
  2001-02-19 21:44 ` Re: Rows in tables... Mitch Vincent <mitch@venux.net>
  2001-02-19 22:41 ` Re: Rows in tables... Dorin Grunberg <dorin@visgen.com>
  2001-02-19 22:50 ` Re: Rows in tables... Dan Wilson <phpPgAdmin@acucore.com>
  0 siblings, 3 replies; 4+ messages in thread

From: Herb Pabst @ 2001-02-19 21:40 UTC (permalink / raw)
  To: pgsql-php

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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Rows in tables...
  2001-02-19 21:40 Rows in tables... Herb Pabst <herbie@nextearth.com>
@ 2001-02-19 21:44 ` Mitch Vincent <mitch@venux.net>
  2 siblings, 0 replies; 4+ messages in thread

From: Mitch Vincent @ 2001-02-19 21:44 UTC (permalink / raw)
  To: herbie@nextearth.com; pgsql-php

SELECT count(*) FROM <tablename>

Then get the count result. You can count a single value in the table if you
want to also..

-Mitch

----- Original Message -----
From: "Herb Pabst" <herbie@nextearth.com>
To: "pgsql-php" <pgsql-php@postgresql.org>
Sent: Monday, February 19, 2001 4:40 PM
Subject: [PHP] Rows in tables...


> 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
>
>




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Rows in tables...
  2001-02-19 21:40 Rows in tables... Herb Pabst <herbie@nextearth.com>
@ 2001-02-19 22:41 ` Dorin Grunberg <dorin@visgen.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Dorin Grunberg @ 2001-02-19 22:41 UTC (permalink / raw)
  To: pgsql-php

Use: pg_NumRows($result)

and

$result = pg_Exec ($conn, $sql);

All the best,
Dorin Grunberg

At 04:40 PM 2/19/2001 -0500, Herb Pabst wrote:
>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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Rows in tables...
  2001-02-19 21:40 Rows in tables... Herb Pabst <herbie@nextearth.com>
@ 2001-02-19 22:50 ` Dan Wilson <phpPgAdmin@acucore.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Dan Wilson @ 2001-02-19 22:50 UTC (permalink / raw)
  To: herbie@nextearth.com; pgsql-php

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
>




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-02-19 22:50 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-19 21:40 Rows in tables... Herb Pabst <herbie@nextearth.com>
2001-02-19 21:44 ` Mitch Vincent <mitch@venux.net>
2001-02-19 22:41 ` Dorin Grunberg <dorin@visgen.com>
2001-02-19 22:50 ` Dan Wilson <phpPgAdmin@acucore.com>

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