lundi 24 août 2020

SQL order by rand() fill result with duplicates if there's not enough rows

I have an exercising app for a language for running tests in 20,40,60 (LIMIT 20..40..60). How to fill result by duplicates if LIMIT exceeds rows in selected topic?

table: topic Cooking has only 18 rows

Lets say "select from table where topic=Cooking order by rand() LIMIT 40

How to populate result by duplicates so that result has 40 rows even there is not enough rows for it?




Aucun commentaire:

Enregistrer un commentaire