lundi 3 avril 2023

Is there a way to get a fixed number of random rows from an SQL table while allowing for repetions

For the example here we will use the table NAMES and I need 3 rows returned.

id name
1 Alpha
2 Beta
3 Chi
4 Delta
5 Epsilon

I know the code SELECT * FROM names ORDER BY RAND() LIMIT 3; will return 3 randomized rows. But it is exclusively three different rows.

Is there a way to in a query get three rows that do not influence each other, and thus allow for repetion? So a result could be Beta, Alpha, Delta. Or Beta, Epsilon, Beta, or even Beta, Beta, Beta.




Aucun commentaire:

Enregistrer un commentaire