From: scott.marlowe <scott.marlowe@ihs.com>
To: Enver ALTIN <enver.altin@frontsite.com.tr>
Cc: pgsql-sql@postgresql.org
Subject: Re: randomized order in select?
Date: Wed, 10 Mar 2004 12:06:04 -0700 (MST)
Message-ID: <Pine.LNX.4.33.0403101205190.11278-100000@css120.ihs.com> (raw)
In-Reply-To: <1078937297.29628.12.camel@enver.office.frontsite.com.tr>
On Wed, 10 Mar 2004, Enver ALTIN wrote:
> 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
You mean like:
select * from table order by random();
That Works as far back as 7.2, maybe before.
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: scott.marlowe@ihs.com, enver.altin@frontsite.com.tr
Subject: Re: randomized order in select?
In-Reply-To: <Pine.LNX.4.33.0403101205190.11278-100000@css120.ihs.com>
* 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