Peter Choe <choepete(at)mindspring(dot)com> writes:
> i do the following:
> select c from charkey where idx=((4 * random())::int)%4;
> sometimes i get one character back (which is good), but other times, i
> get two characters or none.
The WHERE clause is re-evaluated at each row, so you get a new random
value each time. You need to compute *one* random value and then pull
the matching row out of the table.
regards, tom lane