[SQLObject] Select Single Random Record

2012-04-18 Thread Adam Berg
What is the best way to select a single random record from a table and falls within the "where" criteria i have defined? I don't want to return a huge result set each time and then pick a random one, as the database is located outside of my network and accessed over the internet. -- Adam Berg --

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Oleg Broytman
On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg wrote: > What is the best way to select a single random record from a table and > falls within the "where" criteria i have defined? I don't want to return a > huge result set each time and then pick a random one Please define "random" in the

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Hans Georg Schaathun
On Wed, Apr 18, 2012 at 08:38:42PM +0400, Oleg Broytman wrote: > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg > wrote: > > What is the best way to select a single random record from a table and > > falls within the "where" criteria i have defined? I don't want to return a > > huge result s

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Adam Berg
Oleg Broytman phdru.name> writes: > > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg gmail.com> wrote: > > What is the best way to select a single random record from a table and > > falls within the "where" criteria i have defined? I don't want to return a > > huge result set each time an

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Adam Berg
Adam Berg gmail.com> writes: > > Oleg Broytman phdru.name> writes: > > > > > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg gmail.com> > wrote: > > > What is the best way to select a single random record from a table and > > > falls within the "where" criteria i have defined? I don't

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Oleg Broytman
On Wed, Apr 18, 2012 at 05:18:41PM +, Adam Berg wrote: > Oleg Broytman phdru.name> writes: > > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg > > gmail.com> > wrote: > > > What is the best way to select a single random record from a table and > > > falls within the "where" criteria i

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Petr Jakeš
> To give context to the issue, I am building my own icecast2 broadcaster. I > want > to have an Auto DJ feature which will pick a random song from the database > which > hasn't recently been played plus some other criteria. It really doesn't > matter > which record i get back from the database, I

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Pʀoмᴇтнᴇυs 0x01
I'll see about adding a recipe to the SQLObject Community Doc site for this. ( https://sites.google.com/site/sqlobject/ ) On Wed, Apr 18, 2012 at 12:46 PM, Petr Jakeš wrote: > > To give context to the issue, I am building my own icecast2 broadcaster. I >> want >> to have an Auto DJ feature wh

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Hans Georg Schaathun
On Wed, Apr 18, 2012 at 08:46:47PM +0200, Petr Jakeš wrote: > *Get the list of valid IDs from the remote database using the raw SQL > command > something like:* > > con = connectionForURI("firebird://yourUserName:yourPassword@serverAddress > :3050/pat/to/database/database.file") > > validIDs= "SE

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Petr Jakeš
> Although this might work in the particular application, but > it is hardly ideal to make two queries, nor to load a long list > of IDs. Is there a way to do it with a single query? > > 1) Is your task really "time critical"? How many records (IDs) do you expect to be returned using the first sel

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Hans Georg Schaathun
On Wed, Apr 18, 2012 at 09:43:23PM +0200, Petr Jakeš wrote: > > Although this might work in the particular application, but > > it is hardly ideal to make two queries, nor to load a long list > > of IDs. Is there a way to do it with a single query? > > > > 1) > Is your task really "time critical"?

Re: [SQLObject] Select Single Random Record

2012-04-18 Thread Petr Jakeš
> > > Ah. Thanks for the tip. > I will look into it; obviously, I would prefer the solution to > be engine independent, but this feature might be more valuable :-) > > As usually, some good search engine (Google??? :D ) is your friend IMHO you have to always know which SQL engine is on the on