RAND and MySQL version!

2002-05-14 Thread Soheil Shaghaghi

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?

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

Thanks so much,
Soheil


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: RAND and MySQL version!

2002-05-14 Thread Paul DuBois

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


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: RAND and MySQL version!

2002-05-14 Thread Gurhan Ozen

You can't do ORDER BY RAND() prior to version 3.23...

On your 3.22.32 version do something like:

SELECT  column_name*0+RAND() AS rnd FROM table_name WHERE IsActive=1 ORDER
BY rnd LIMIT 1;

Gurhan

-Original Message-
From: Soheil Shaghaghi [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 14, 2002 4:26 PM
To: [EMAIL PROTECTED]
Subject: RAND and MySQL version!


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?

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

Thanks so much,
Soheil


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php