Reputation: 1007
I need to take 10 rows from table. It has to be random but in that table I have only 5 rows. And so if I select:
SELECT * FROM `names` order by rand() limit 10
But this query returns me only 5.
How to get five more with repeat?
Upvotes: 0
Views: 101
Reputation: 791
SELECT m.* FROM
names
m,names
n order by rand() limit 10
This may be what you wanted
Upvotes: 2
Reputation: 4888
Try like
SELECT * FROM names
UNION ALL
SELECT * FROM names
ORDER BY RAND() LIMIT 10;
Upvotes: 0