You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Joe Taylor <jo...@jtinnovations.com> on 2003/05/23 22:36:12 UTC

ojb newbie question

So far I like the little I've seen with OJB, however I have been stumped 
with the following and can't seem to find the answer anywhere - 
hopefully someone can help.

 I would like to use the   rand()  command for a query (MySQL) and to 
accomplish this I need to have  "ORDER BY rand()" at the end of my 
SELECT, however I cannot see a way to do this via the addOrderBy because 
it references fields - so I tried addSQL(Ie. criteria.addSql("ORDER BY 
rand()");), however that results in the addition of a WHERE if there is 
none already (Ie."WHERE ORDER BY rand()") -or- if there is a WHERE it 
adds an AND (Ie."WHERE field=something AND ORDER BY rand()").  I would 
suspect that if I wanted to append the LIMIT statement to my select I 
would run into the same problem.

I'm sure just being new to this stuff I'm just missing something, so any 
help would be appreciated.

Thanks in advance,
Joe