I use this to get a random row from a table:

Criteria crit = new Criteria();
crit.addAsColumn("rnd", "rand()");
crit.addAscendingOrderByColumn("rnd");
crit.setLimit(1);
YourTableNamePeer.doSelect(crit);

hope it helps

-----Original Message-----
From: William Wong [mailto:[EMAIL PROTECTED] 
Sent: Domingo, 18 de Enero de 2004 10:32 p.m.
To: [EMAIL PROTECTED]
Subject: Criteria question...


Hi All,

Is there any easy way to convert below Mysql select statement into a
Criteria statement?

select * from name order by rand() limit 1;

Can I use Criteria.CUSTOM to achieve it?

Thank you in advance.

Regards,
William


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to