> However....what about when a row has been deleted, ie there is now id
which
> matches the condition?
> I suppose then it gets a bit tricky with a stored procedure loop thing....
>
generally no, the ID is no longer a "record". but you could generate a
number which corresponds to an ID which no longer exists-- however if
handling this as a SP, it is easy to get all the records possible (and
possibly filtered) and then pick one. if a second query to get that records
details generates no results then that ID was no good so just do it again.
The efficiency will be determined by whether this is a table that gets a lot
of deletes or not :) And depending on how you've contructed your DB you
might even have a field like IsActive_YN which can further limit the results
of the first filtering to only those records you care about anyway
BTW, If you're returning the info to CF before the random pick, then it's
best to return only the ID's. Then pick one (random). Then do SELECT for
that ID to get all the records details that you need
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists