DISQUS

Tech-Recipes: Select a random record. | PostgreSQL PgSQL | Tech-Recipes

  • Anonymous · 5 years ago
    Just a little bit easier:

    SELECT cat, dog
    FROM foo
    ORDER BY random()
    LIMIT 1;
  • Chad · 5 years ago
    select .... order by random() limit 1
  • Anonymous · 5 years ago
    <ul id="quote"><h6>Anonymous wrote:</h6>Just a little bit easier:

    SELECT cat, dog
    FROM foo
    ORDER BY random()
    LIMIT 1;</ul>
  • Anonymous · 5 years ago
    select ... order by rand()
  • Anonymous · 4 years ago
    THe reason the author did it this way is because its the fastest performance wise. You are right in stating that order by rand() is more compact when speaking about code but this example is all about speed now.