Using PHP and MySQL, I want to select only 6 rows from table which has more rows everyday. I try to use the code like:
SELECT * FROM table WHERE rand()<=$fragment LIMIT 6
where fragment is 6 divided by number of total rows. The number of rows in result mostly be 6, but sometime less than 6.
How to get the result that have exactly six rows?
That will always give you exactly 6 rows selected randomly (as long as there are at least 6 rows in your table).