Skip site navigation (1) Skip section navigation (2)

Re: randomized order in select?

From: Enver ALTIN <enver(dot)altin(at)frontsite(dot)com(dot)tr>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: randomized order in select?
Date: 2004-03-10 23:15:22
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Wed, 2004-03-10 at 13:02 -0600, Bruno Wolff III wrote:
> You can but it won't be very efficient (for large tables) as it will generate
> a random ordering for the whole table, probably do a sort and then return the
> first record.  The only thing different you need to do is add () after random:
> select tiptext from tips order by random() limit 1

Thanks. The whole table consists of about 100 rows and I don't think it
will grow by, even twice. So this fits my needs just well.
|          |
|          |  Enver ALTIN (a.k.a. skyblue)
|          |  Software developer, IT consultant
|    FRONT |
|==========|  FrontSITE Bilgi Teknolojisi A.Ş.

In response to

pgsql-sql by date

Next:From: azwaDate: 2004-03-11 01:51:08
Subject: Re: designer tool connect to PostgreSQL
Previous:From: Daniel Henrique Alves LimaDate: 2004-03-10 23:00:14
Subject: About pg_dump

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group