random() function?

241 views
Skip to first unread message

limbic...@gmail.com

unread,
Dec 28, 2008, 10:48:48 PM12/28/08
to H2 Database
Is there a random() function in H2? I'd like to do something like the
following:

select * from my_table order by random() limit 1

to get a random row from my_table.

Thanks

Thomas Mueller

unread,
Jan 3, 2009, 6:18:51 AM1/3/09
to h2-da...@googlegroups.com
Hi,

I have a question. Is the integrated search function in the web site
working for you? On the web site http://h2database.com if I click on
the field below "Search:" on the far left and type 'rand' I get a link
to 'Functions'. If I click on it, I am redirected to

http://www.h2database.com/html/functions.html?highlight=RAND&search=rand#firstFound

If I then click on the yellow 'RAND' I am redirected to

http://www.h2database.com/html/functions.html?highlight=RAND&search=rand#rand

Maybe you have disabled Javascript? If yes why? If not, what browser
are you using?

Regards,
Thomas

Limbic System

unread,
Jan 3, 2009, 8:52:32 AM1/3/09
to h2-da...@googlegroups.com
Hi Thomas,

I just checked and the integrated search is indeed working fine for me
(Safari on Mac). I had searched for "random" on the functions page
using my browser's built-in search capability and found "RANDOM_UUID",
but I missed the "RAND" function. I guess I'm just not used to sites'
built-in search working well enough to trust them. :-) Thanks for the
pointer, and sorry for wasting your time.

Thomas Mueller

unread,
Jan 3, 2009, 2:10:09 PM1/3/09
to h2-da...@googlegroups.com
Hi,

> I just checked and the integrated search is indeed working fine for me
> (Safari on Mac).

Good to know it works. There were some problems with this feature on
some browsers some time ago. Also the search box may be at the wrong
position (left instead of right top).

> "RANDOM_UUID", but I missed the "RAND" function

There should probably be a one line description for each function at
the very top (similar to Javadoc). Like that the RAND would be the
first link. Also the weight of the 'Functions' page should be above
'Advanced Topics'. I will add a feature request for that.

> Thanks for the
> pointer, and sorry for wasting your time.

It's not wasting time. The usability is very important, and if the
documentation search is not working correctly then it's a problem.

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages