RE: order by rand() question

2001-06-15 Thread Jon Haworth
I don't think the answer has changed since last week :-) IMHO it's not really slow and inefficient, anyway - this script: ---start--- ?php $db = mysql_connect(localhost, root, :-)); mysql_select_db(Playground, $db); mysql_query(CREATE TABLE mytable (myfield INTEGER UNSIGNED, PRIMARY KEY

Re: order by rand() question

2001-06-15 Thread Gerald Clark
You asked this earlier this week. The answer has not changed. Matt Heaton wrote: Hi all, trying to do something and have it be as efficient as possilble. My question is if I have a table with say 10,000 rows in it, and I issue a command like this select * from table where number=1 order

RE: order by rand() question

2001-06-15 Thread Chris Bolt
I don't think the answer has changed since last week :-) IMHO it's not really slow and inefficient, anyway - this script: (clipped) produces a table with 1 rows each containing an integer. Then we do: mysql SELECT * FROM mytable ORDER BY RAND() LIMIT 5; (clipped) 5 rows in set (0.08

Re: order by rand() question

2001-06-15 Thread Chris Petersen
In a slight change of this question (since I have no data to currently test this with, as my ISP is using too old a version of mysql), does anyone know what something like this would do? SELECT * FROM theTable ORDER BY RAND(), date LIMIT 5; I'd like to be able to pull out a certain number of

RE: order by rand() question

2001-06-15 Thread Chris Bolt
In a slight change of this question (since I have no data to currently test this with, as my ISP is using too old a version of mysql), does anyone know what something like this would do? SELECT * FROM theTable ORDER BY RAND(), date LIMIT 5; Exactly the same as SELECT * FROM theTable ORDER

RE: order by rand() question

2001-06-15 Thread Chris Bolt
Gotcha. So is there any way to return 5 (some number) rows, chosen randomly, and then sort them by date (or name or whatever). So the final result is a list, sorted by date, but of rows chosen randomly from the table. CREATE TEMPORARY TABLE temptable TYPE=HEAP SELECT * FROM theTable ORDER

Re: order by rand() question

2001-06-15 Thread Chris Petersen
In a slight change of this question (since I have no data to currently test this with, as my ISP is using too old a version of mysql), does anyone know what something like this would do? SELECT * FROM theTable ORDER BY RAND(), date LIMIT 5; Exactly the same as SELECT * FROM theTable