List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 14 2002 8:40pm
Subject:Re: RAND and MySQL version!
View as plain text  
At 13:26 -0700 5/14/02, Soheil Shaghaghi wrote:
>Hello All,
>I am running 2 MySQL servers, one on Linux, and the other on FreeBSD.
>Linux, MySQL version: 3.23.49
>FreeBSD, MySQL version: 3.22.32
>
>Problem:
>
>The following code runs on the newer version of MySQL, and Linux, but when I
>run it on the other server, I get sql error.
>
>SELECT ID,Headlines,IsActive FROM DATABASE WHERE IsActive=1 ORDER BY RAND()
>LIMIT 1
>
>Can anyone please tell me if it's the version of MySQL causing this problem
>or something else?

Yes.  Expressions in the ORDER BY clause are not supported prior to 3.23.2.

>
>Is there anyway to get around this, without upgrading MySQL?

SELECT ID*0+RAND() AS r, ID, Headlines, ... ORDER BY r LIMIT 1;

>
>Thanks so much,
>Soheil

Thread
A table setup question.MySQL Newsgroup14 May
  • RAND and MySQL version!Soheil Shaghaghi14 May
    • Re: RAND and MySQL version!Paul DuBois14 May
    • RE: RAND and MySQL version!Gurhan Ozen14 May
  • RE: A table setup question.Roger Baklund14 May