List:General Discussion« Previous MessageNext Message »
From:Sinisa Milivojevic Date:March 26 2001 11:34am
Subject:Re: SELECT... ORDER BY RAND() LIMIT x FAILS
View as plain text  
shawn@stripped writes:
 > >Description:
 > The documentation says that I can do:
 > select * from table order by rand() limit 10
 > as an example, however it fails and there is no error message.
 > I *can* do:
 > select * from table order by rand()
 > which works fine.  It just seems that adding the limit clause causes
 > something to break.
 > >How-To-Repeat:
 > Easy way:
 > mysql mysql
 > select * from users order by rand() limit 10
 > On my database machine using the latest stable binray release it fails.
 > >Fix:
 > None known
 > 
 > >Submitter-Id:	<submitter ID>
 > >Originator:	Shawn Wallace
 > >Organization:
 > Justweb Inc.
 > >MySQL support: [none | licence | email support | extended email support ]
 > >Synopsis:	Problem combining order by rand() with limit
 > >Severity:	serious
 > >Priority:	medium
 > >Category:	mysql
 > >Class:		sw-bug
 > >Release:	mysql-3.23.35 (Official MySQL RPM)
 > >Server: /usr/bin/mysqladmin  Ver 8.18 Distrib 3.23.35, for pc-linux-gnu on i686
 > Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 > This software comes with ABSOLUTELY NO WARRANTY. This is free software,
 > and you are welcome to modify and redistribute it under the GPL license
 > 
 > Server version		3.23.35
 > Protocol version	10
 > Connection		Localhost via UNIX socket
 > UNIX socket		/var/lib/mysql/mysql.sock
 > Uptime:			5 hours 56 min 1 sec
 > 
 > Threads: 3  Questions: 160022  Slow queries: 0  Opens: 106  Flush tables: 1  Open
tables: 100 Queries per second avg: 7.491
 > >Environment:
 > 	
 > System: Linux darthvader 2.2.18pre21-RAID #2 Wed Feb 14 17:21:03 EST 2001 i686
unknown
 > Architecture: i686
 > 
 > Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gcc /usr/bin/cc
 > GCC: Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
 > gcc version 2.95.2 20000220 (Debian GNU/Linux)
 > Compilation info: CC='egcs'  CFLAGS='-O6 -fomit-frame-pointer -mpentium'  CXX='egcs'
 CXXFLAGS='-O6 -fomit-frame-pointer 	          -felide-constructors -fno-exceptions
-fno-rtti -mpentium'  LDFLAGS=''
 > LIBC: 
 > lrwxrwxrwx    1 root     root           13 Mar 12 13:22 /lib/libc.so.6 ->
libc-2.1.3.so
 > -rwxr-xr-x    1 root     root       887712 Jan 15 15:06 /lib/libc-2.1.3.so
 > -rw-r--r--    1 root     root      2089496 Jan 15 15:07 /usr/lib/libc.a
 > -rw-r--r--    1 root     root          178 Jan 15 15:07 /usr/lib/libc.so
 > Configure command: ./configure  --disable-shared --with-mysqld-ldflags=-all-static
--with-client-ldflags=-all-static --enable-assembler --with-mysqld-user=mysql
--with-unix-socket-path=/var/lib/mysql/mysql.sock --prefix=/
--with-extra-charsets=complex --exec-prefix=/usr --libexecdir=/usr/sbin --sysconfdir=/etc
--datadir=/usr/share --localstatedir=/var/lib/mysql --infodir=/usr/info
--includedir=/usr/include --mandir=/usr/man --without-berkeley-db --without-innobase
'--with-comment=Official MySQL RPM'
 > Perl: This is perl, version 5.005_03 built for i386-linux


Hi!

I tested the above and it worked just fine for me.

What exactly did not work. Please check that your table is not
corrupt.


Regards,

Sinisa

      ____  __     _____   _____  ___     ==  MySQL AB
     /*/\*\/\*\   /*/ \*\ /*/ \*\ |*|     Sinisa Milivojevic
    /*/ /*/ /*/   \*\_   |*|   |*||*|     mailto:sinisa@stripped
   /*/ /*/ /*/\*\/*/  \*\|*|   |*||*|     Larnaca, Cyprus
  /*/     /*/  /*/\*\_/*/ \*\_/*/ |*|____
  ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^
             /*/             \*\                Developers Team
Thread
SELECT... ORDER BY RAND() LIMIT x FAILSshawn26 Mar
  • Re: SELECT... ORDER BY RAND() LIMIT x FAILSSinisa Milivojevic26 Mar