This content has been marked as final. Show 4 replies
Instead if recordCount run a Select query like
This will return the largest auto-generated ID, you will still have to
check for missing ones.
There are probable better overall methods to do what you desire, but
this is a quick fix for you.
Simply select a single record at random directly from the table, rather than to get into checking for its existence etc. Use something like the following query to do this:
SELECT TOP 1 *
ORDER BY NewID()
SELECT yourfield FROM yourtable WHERE ... ORDER BY rand() LIMIT 1
SELECT TOP 1 yourfield FROM yourtable WHERE ... ORDER BY newid()
SELECT TOP 1 yourfield FROM yourtable WHERE ... ORDER BY
RND(yourprimarykey) [warning: this may not be random through CF]
Thanks, that seem to work fine