consigliere
consigliere

Reputation: 1007

MySQL select random 10 rows from 5

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

Answers (2)

Chandra Prakash
Chandra Prakash

Reputation: 791

SELECT m.* FROM names m,names n order by rand() limit 10

This may be what you wanted

Upvotes: 2

Abdul Manaf
Abdul Manaf

Reputation: 4888

Try like

SELECT * FROM names 
UNION ALL 
SELECT * FROM names 
ORDER BY RAND() LIMIT 10;

Upvotes: 0

Related Questions