On Mon, May 21, 2001 at 11:32:46AM +0530, Adrian D'Costa wrote:
> Hi,
>
> I have been trying this on my localhost and this works
>
> select special.contid, special.cityid, special.curr1, special.catalogo,
> special.hf, special.curr2, special.vitofferta, special.fh, special.club,
> special.stars, city.city from special,city where
> DATE_SUB(special.periodo, INTERVAL 3 DAY) >'$tdate' and
> city.id=special.cityid order by RAND() limit 1
>
> My version
> +------------------+
> | version() |
> +------------------+
> | 3.23.22-beta-log |
> +------------------+
>
> but the same sql statement on my online server does not work.
> select special.contid, special.cityid, special.curr1, special.catalogo,
> -> special.hf, special.curr2, special.vitofferta, special.fh,
> special.club,
> special.stars, city.city from special,city where
> DATE_SUB(special.periodo, INTERVAL 3
> -> DAY) >'$tdate' and city.id=special.cityid order by RAND() limit 1;
> ERROR 1064: You have an error in your SQL syntax near 'RAND() limit 1' at
> line 3
>
> select version();
> +-----------+
> | version() |
> +-----------+
> | 3.22.32 |
> +-----------+
>
> What could be the problem
A very-very-very quick search for 'ORDER BY RAND' in the MySQL manual
turned up the following at the middle of the documentation of the RAND()
function:
You can't use a column with `RAND()' values in an `ORDER BY'
clause, because `ORDER BY' would evaluate the column multiple
times. In *MySQL* Version 3.23, you can, however, do: `SELECT *
FROM table_name ORDER BY RAND()'
It does say 'in MySQL version 3.23', doesn't it now? :) 3.22 does not
support this syntax.
G'luck,
Peter
--
Nostalgia ain't what it used to be.
---------------------------------------------------------------------
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