How can I randomly select a record in a database that meets a condition (that is, it is also possible to use the WHILE).
mysql_query("SELECT * FROM mitabla WHERE cat=4 ORDER BY RAND() LIMIT 1");
That example would be fine?
How can I randomly select a record in a database that meets a condition (that is, it is also possible to use the WHILE).
mysql_query("SELECT * FROM mitabla WHERE cat=4 ORDER BY RAND() LIMIT 1");
That example would be fine?
a rand from 1 could be applied to the maximum id value of all records
example:
mysql_query("SELECT * FROM mitabla WHERE cat=4 and id=FLOOR(RAND()*((SELECT max(id) FROM mitabla WHERE cat=4)-1+1)+1) LIMIT 1");