[ic] Does ORDER BY rand() work in sql query ?

Jim Toro interchange-users@icdevgroup.org
Fri Jun 28 16:12:01 2002


I am able to do a mySQL query via command line mysql client on the server
as "select * from products
     where PurchasedZip LIKE 10101  ORDER BY rand() LIMIT 500"
and I can do the same search in IC with no problem if I use the following
form with the exception of the "rand()" sorting:

 <form action="[process-search]" method="post">
 <input type="hidden" name="mv_searchtype" value="sql">
 <input type="hidden" name="mv_matchlimit" value="500">
 <input type="text" size="20" name="searchzip" value="">
 <input type="hidden" name="mv_sql_query" value="select * from products
     where PurchasedZip LIKE searchzip ORDER BY rand() LIMIT 500">
 <input type="submit" name="mv-todo" value="Search">
 </FORM>

If I remove the "ORDER BY rand()" its perfect. If I leave it in the
results page shows "BAD_SQL" and the error.log from the account shows
the errors below:


xxx.xxx.xxx.xxx zC2YzcLs:xxx.xxx.xxx.xxx - [28/June/2002:15:55:05 -0400]
localflorist
/cgi-bin/localflorist/search.html SQL query failed: Bad SQL statement:
Parse error
near () LIMIT 500 at /usr/local/interchange/lib/Vend/Scan.pm line 586.
>
> Query was: select * from products where PurchasedZip LIKE searchzip
ORDER BY rand()
LIMIT 500 at /usr/local/interchange/lib/Vend/Interpolate.pm line 3453
>
> query was: select * from products where PurchasedZip LIKE searchzip
ORDER BY rand()
LIMIT 500

Any idea if its something to do with the rand() order statement itself or
something about IC trying to get random info from the server or what?.
I am running IC 4.8.3 , FreeBSD 4.3 and Apache 1.3.19.

-----------------------------------------------------------------------
---------  House Of Files Internet -   http://www.hofweb.com   --------
       Call Anytime -  516-938-2421  or  Toll Free 1-866-546-8676
Frontpage 2002 / ASP / Share Point Services / Access and MySQL Databases
 Interchange 4.8.x / PDG Cart / Salescart E-Commerce Hosting and Support
   Need DLL's registered or special Perl Modules?. Ask and it's done !
 --------- Serving Long Island's online community since 1985 ----------