X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2AB56D1DC9E for ; Wed, 10 Mar 2004 19:10:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18606-02 for ; Wed, 10 Mar 2004 15:09:49 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 78184D1DC4D for ; Wed, 10 Mar 2004 15:08:55 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i2AJ7hSn000803; Wed, 10 Mar 2004 12:07:43 -0700 (MST) Date: Wed, 10 Mar 2004 12:06:04 -0700 (MST) From: "scott.marlowe" To: Enver ALTIN Cc: Subject: Re: randomized order in select? In-Reply-To: <1078937297.29628.12.camel@enver.office.frontsite.com.tr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/111 X-Sequence-Number: 17210 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.