The raw SQL for PostgreSQL:

SELECT col FROM tab ORDER BY random() LIMIT 1;

I happened to see this on http://wiki.postgresql.org/wiki/FAQ

Regards
Anand

On Sep 9, 8:07 pm, Richard <richar...@gmail.com> wrote:
> hi,
>
> is there an efficient way to get a random record from a table?
> An obvious non-efficient way would be to get all the records and do
> random.choice().
>
> thanks,
> Richard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to