Ask a Question related to PHP Development, Design and Development.
-
justin at visunet dot ie #1
#22597 [Com]: PHP can't select random rows from MySql
ID: 22597
Comment by: justin at visunet dot ie
Reported By: grugli at mmedia dot is
Status: Bogus
Bug Type: MySQL related
Operating System: Windows XP
PHP Version: 4.3.1
New Comment:
When you say:
This MySql-query doesn't seem to work.
$Query = "select * from $TableName ORDER BY RAND() LIMIT 1";
The only thing that the query returns is the first row and nothing
else.
1) Limit should be used like so .. LIMIT 0,1
2) In the above example LIMIT makes mySQL returns the first row and
nothing else.
Previous Comments:
------------------------------------------------------------------------
[2003-04-29 05:06:55] mir at irczone dot dk
I have this problem too, using PHP 4.3.0 on Mac OS X
10.2.5 and also on FreeBSD 4.7 with PHP 4.3.1 both
running as a module in Apache 1.3.27 and talking with a
MySQL 3.23.54 server. When using the mysql client on
the commmandline, the RAND() works fine.
It worked before, with the exact same code,
unfortunately I don't know which version of PHP broke
it - my guess would be PHP 4.3.
Hope you can fix this ASAP.
------------------------------------------------------------------------
[2003-03-17 09:52:19] gaui at gaui dot is
Ok, this problem persists here and is VERY annoying.
Please fix this.
------------------------------------------------------------------------
[2003-03-12 21:12:37] genius at airmail dot net
I made the previous comment too quickly, it appears to me that this
indeed is a php (for win32 .. cause it tested on linux w/o problems)
problem.
when running mysql command line this command 'select * from pictures
order by rand()' produces random results, however when calling that
same command from php it always returns the same result.
in my previous post i was running 'select * from pictures order by
rand(now())' from the command line which returns the same result every
time, which lead me to believe the bug was in mysql.
someone please reopen this bug report
------------------------------------------------------------------------
[2003-03-12 20:45:54] genius at airmail dot net
The bug is in mysql as I can reproduce it from the command-line. It
also may be windows-specific ... this bug is often mistaken for not
providing a random seed i.e. rand(now()) but the problem persists even
with the seed.
------------------------------------------------------------------------
[2003-03-08 05:27:47] [email]georg@php.net[/email]
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit [url]http://www.php.net/support.php[/url] as this bug system is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
PHP uses the same api call (mysql_query/mysql_real_query) as in mysql
command line client and it doesn't change the query string.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
[url]http://bugs.php.net/22597[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=22597&edit=1[/url]
justin at visunet dot ie Guest
-
Select Multiple Rows within CFGRID?
Is it possible to select multiple records within a CFGRID? -
Select datagrid rows with key-up and key-down?
I have an application that uses a windows forms datagrid. How do I select rows using the up-arrow and down-arrow keys? Mervin Williams -
How to select first 50 rows?
Hi guys, If i have a total 500 rows of records set, but i need to return 50 rows at one time by a sql statement. Do you know how to do that? ... -
limiting rows returned in a sql select
ceprnatwork@hotmail.com (the dragon) wrote in message news:<6e59cc25.0308200651.6edb0e2@posting.google.com>... I dont know why "fetch first ...",... -
Select rows where other related rows don't exist
I would like to select rows from a table where another related row in the same table doesn't exist and the relation key is more than 1 column. ...



Reply With Quote

