From: | Justin Long <justinlong(at)strategicnetwork(dot)org> |
---|---|
To: | "'pgsql-sql(at)postgreSQL(dot)org'" <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | Selecting random element? |
Date: | 2000-03-06 15:31:39 |
Message-ID: | 01BF8757.2898CBB0.justinlong@strategicnetwork.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Does anyone have a way to select a random element without doing a complete select on the database first?
For example, right now I would have to (under PHP3):
$rs = pg_exec($db,"SELECT * FROM database");
$rec = pg_fetch_object($rs,rand(1,pg_numrows($rs)));
It would be a lot easier to just do a
$rs = pg_exec($db,"SELECT * from database RANDOM")
or some such where it would select a random row.
_____
Justin Long
Network for Strategic Missions
1732 South Park Court, Chesapeake, VA 23320
Ofc 757-420-4500, Fax 757-226-5006, Email justinlong(at)strategicnetwork(dot)org
Never retreat. Never surrender. Never cut a deal with a dragon.
http://www.strategicnetwork.org
From | Date | Subject | |
---|---|---|---|
Next Message | Kief Morris | 2000-03-06 15:54:42 | Returning multiple rows in functions |
Previous Message | Justin Long | 2000-03-06 15:27:16 | RE: [SQL] database with 1000000 rows is very slow |