From a MySQL database how can I randomly selected the data I use with mysql_query($query)?
I think that creating an array and using the rand() function is my only choice. This takes a lot of resources when I'm pulling 10,000 rows. Any Ideas?
Random Selection
Started by dirkfirst, Oct 21 2006 06:37 AM
5 replies to this topic
#1
Posted 21 October 2006 - 06:37 AM
|
|
|
#3
Guest_Jordan_*
Posted 22 October 2006 - 03:11 PM
Guest_Jordan_*
Just use the rand() function of MySQL.
SELECT * FROM tbl ORDER BY RAND() LIMIT 1;
#4
Posted 23 October 2006 - 10:46 AM
I don't know if I'm asking this in the right room but here it goes. Where do I put a random function If I am trying to make random links for articles on homepage show up in different areas.
Down the Tracks |Submit Links Here[SIGPIC][/SIGPIC]
#5
Guest_Jordan_*
Posted 23 October 2006 - 05:32 PM
Guest_Jordan_*
If you want it on your homepage put it on your homepage. Are you using the mysql random function from above?
#6
Posted 26 October 2006 - 07:29 AM
Jordan said:
Just use the rand() function of MySQL.
SELECT * FROM tbl ORDER BY RAND() LIMIT 1;
Thanks, works perfect.


Sign In
Create Account


Back to top









