Hi, I know that it is possible, but how do you select a random row from a mysql database. Im not talking about the php rand(), I mean the mysql actual function for it. Thanx for you help!
try: SELECT * FROM table GROUP BY RAND() LIMIT 1;
don't you mean 'order by rand()'?
on mysql version 3.22 use
SELECT , ((id0)+rand()) AS random FROM table ORDER BY random LIMIT 1
substitute id with the name of your id-field.
God bless you, Clemens!
Here's my code--so others can see how it looks in real life
SELECT , ((id0)+rand()) AS random, firstname, id, verified, city, state, country FROM table WHERE checked = 'Y' and featured = 'Y' ORDER BY random LIMIT 1
What is the point to ((id*0)+rand())? isn't that the same as 0 + rand() ??
I'm not 100% sure myself :-)
Probably a MYSQL thing, it may be that in onlder versions of mysql you couldn't use "rand()" without refering to a field value, or something stupid like that (sounds very MySQL-ish)
It took a few versions before it became possible to order by "rand()" too.