Comment obtenir des lignes aléatoires à partir d’une requête SQL - PostgreSQL

Comment obtenir une ligne aléatoire à partir d'une requête SQL - PostgreSQL

How can i get a random row from a query result in PostgreSQL?
La réponse est simple, il suffit d'utiliser la fonction intégrée RANDOM () dans PostgreSQL

SELECT scoreid FROM n_score ORDER BY RANDOM() limit 1;

L'exemple ci-dessus obtiendra un identifiant de score aléatoire à partir de la table n_score. À chaque exécution, il obtiendra un identifiant de score aléatoire. Terminé.