List:General Discussion« Previous MessageNext Message »
From:Adam Fortuno Date:September 11 2003 12:31am
Subject:RE: how to do a random ORDER BY in a SELECT statement
View as plain text  
Comcast,

Simply order by the random function, RAND(). For example:

  SELECT aff.*
    FROM financial_affiliates AS aff
   WHERE aff.state = 'wa'
     AND aff.category = '3'
ORDER BY RAND();

Regards,
Adam

-----Original Message-----
From: Comcast [mailto:m.devries@stripped]
Sent: Wednesday, September 10, 2003 8:05 PM
To: mysql@stripped
Subject: how to do a random ORDER BY in a SELECT statement


I am querying a table and using the following statement:

SELECT * FROM financial_affiliates WHERE state = 'wa' AND category = '3'
ORDER BY name

I would like to ORDER BY RANDOM - is there an easy way to do that. 

Thanks.

-Doug
Thread
how to do a random ORDER BY in a SELECT statementComcast11 Sep
  • Re: how to do a random ORDER BY in a SELECT statementDavid T-G11 Sep
    • Re: how to do a random ORDER BY in a SELECT statementDavid T-G11 Sep
RE: how to do a random ORDER BY in a SELECT statementAdam Fortuno11 Sep