From: Enver ALTIN <enver.altin@frontsite.com.tr>
To: pgsql-sql@postgresql.org
Subject: randomized order in select?
Date: Wed, 10 Mar 2004 18:48:17 +0200
Message-ID: <1078937297.29628.12.camel@enver.office.frontsite.com.tr> (raw)
Hi,
I have got a simple table like this:
create table tips (
id integer primary key unique,
tiptext text
);
and, I've got a website where I'm willing to show these tips in a random
order. Each visitor will get a randomly selected tip. So for now, I have
to do 2 queries:
select id from tips
collect an ID list, choose one randomly and retrieve it. I wish I could
do something like:
select tiptext from tips order by random limit 1
in PostgreSQL.
--
__________
| |
| | Enver ALTIN (a.k.a. skyblue)
| | Software developer, IT consultant
| FRONT |
|==========| FrontSITE Bilgi Teknolojisi A.Þ.
|_____SITE_| http://www.frontsite.com.tr/Attachments:
signature.asc (application/pgp-signature, 188B) download
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: enver.altin@frontsite.com.tr
Subject: Re: randomized order in select?
In-Reply-To: <1078937297.29628.12.camel@enver.office.frontsite.com.tr>
* 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