Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 returning random records from MS access database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-28 : 08:23:48
vaithi writes "Hi

I want to generate the image and its description from the acces database randomly.

How it can be done.

Can u help me?

Thanks

Vaithi"

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2002-04-30 : 03:37:12
Vaithi,

I take it you're trying to return a random record from a table?

If so, here's how (assuming your table has an identity column):

SELECT TOP 1 *
FROM Table1
WHERE Table1.ID >= (SELECT Cint(Rnd() * Max(Table1.ID)) FROM Table1)

This determines the maximum value in the identity column, multiplies this by a random (0-1) number, then returns the first record whose identity column is equal or greater than this number




Go to Top of Page
   

- Advertisement -