Hello,
I am trying to use a SQL Query to return a random record from an
Access 2000 Database.
I am using:
SELECT TOP 1 Example
FROM TABLE
ORDER BY Rnd[(ID)];
But, I am not getting a random record, I get the same record returned
each time. If I create a SQL query in Access, and use the order by
rnd, I will get a random record.
Does anyone know how to return a random record with a SQL query?
Thank you for the help,
Bill Kramer 7 6939
I have no idea on how this works, but I did find a solution (I think)
Try:
Sorry, previous post left me too fast...
Here is the syntax (x = table, ID = field)
SELECT TOP 1 x.ID
FROM x
ORDER BY Rnd([id])*[id]*Now();
This works for me
Thank you very much for your reply. Unfortunately I wasn't able to get
your code to work for me. I haven't found a solution yet.
But thank you very much for your effort.
-Bill Kramer
"WindAndWav es" <ac****@ngaru.c om> wrote in message news:<P4******* ***********@new s.xtra.co.nz>.. . Sorry, previous post left me too fast...
Here is the syntax (x = table, ID = field)
SELECT TOP 1 x.ID FROM x ORDER BY Rnd([id])*[id]*Now();
This works for me
This works, but it always pulls the same data! I guess the starting
SEED is not accurate?
WindAndWaves wrote: Sorry, previous post left me too fast...
Here is the syntax (x = table, ID = field)
SELECT TOP 1 x.ID FROM x ORDER BY Rnd([id])*[id]*Now();
This works for me
This works, but it always pulls the same data! I guess the starting
SEED is not accurate?
WindAndWaves wrote: Sorry, previous post left me too fast...
Here is the syntax (x = table, ID = field)
SELECT TOP 1 x.ID FROM x ORDER BY Rnd([id])*[id]*Now();
This works for me
You need to use the Randomize method first. Check the Help file.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications re******@pcdata sheet.com www.pcdatasheet.com
"gmsmstr" <dm*******@surd yke.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . This works, but it always pulls the same data! I guess the starting SEED is not accurate?
WindAndWaves wrote: Sorry, previous post left me too fast...
Here is the syntax (x = table, ID = field)
SELECT TOP 1 x.ID FROM x ORDER BY Rnd([id])*[id]*Now();
This works for me
The ORDER BY clause does not affect which records are chosen, only the order
in which the records that have been selected are presented. You would need a
WHERE or HAVING clause to affect the selection.
Just for the record, RANDOMIZEing prior to executing this SQL will have no
effect on the records returned.
Larry Linson
Microsoft Access MVP
"gmsmstr" <dm*******@surd yke.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . This works, but it always pulls the same data! I guess the starting SEED is not accurate?
WindAndWaves wrote: Sorry, previous post left me too fast...
Here is the syntax (x = table, ID = field)
SELECT TOP 1 x.ID FROM x ORDER BY Rnd([id])*[id]*Now();
This works for me This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Keith Griffiths |
last post by:
I'm trying to do a search under a set criteria followed by a selection of
random entries meeting this criteria. But I don't seem to be able to
achieve this.
The idea being to search on say subject and then select a random set of
records meeting that subject.
Any ideas or thought would be helpful. I'm using Access XP to try this out.
TIA
|
by: Stefanie |
last post by:
Hi,
I have a question about declaring variables for writing data to a file for
random access.
I have two string variables declared in a module (user-defined types).
The point is that for one of them i can't define (hard coded) a fixed
length because the application is reading data
from another file (In that file they have the same lenght).
Is it possible to use the lenght i obtain from reading that other file to
declare my variable or...
|
by: Ini |
last post by:
Hi,
Is there an easy way to pick at random one record out of a recordset and
then leave this recordset?
I was thinking about doing a recordcount of the recordset, then find at
random the number between 1 and <recordcount> and then move to this record
in the recordset.
There is a easier way, isn't it?
|
by: anita |
last post by:
I had posted this question before, but did not hear from anybody.
Can somebody pls help me out.
I am creating a table with two fields F1, F2 and F2 has about 50,000
randomly generated alphanumeric nos(RandomID)stored in the combobox
control. Everytime I enter a new record in F1, the next available
RandomID should be automatically assigned to the new record entry and
displayed in the respective form control(F2). Can anybody guide me...
|
by: sugaray |
last post by:
I want to write a school computer billing system, one of the function
is to distribute machine id using rand() for each student log on,
suppose there's 100 machines, when each person log on, the system will
store user's info such as name, student id number, log on time, log
out time into a database file, when the next student log on, the
function loads the database, and compare the random generated machine
id with the existing ids store...
| |
by: Pete via DotNetMonster.com |
last post by:
Hi,
I need to display a different random record or link each day. I have the
random part working so that if the browser is refreshed a new record will
display. I'm not sure however how to specify that it only happens once a
day. This is the select statement I'm using to generate a random record.
Dim queryString As String = "SELECT Top 1 . FROM
ORDER BY NEWID()"
|
by: Jimmy |
last post by:
ill have a database with 1 table and 3 fields:
ID FIRSTNAME LASTNAME
(the ID field will be the auto incrementing index)
there might be 10 records in the DB, there might be 10,000.
i need to open the DB and randomly select a record (and then display the
name, which i dont have a problem with)
how can i randomly select a record? im guessing id have to open a recordset
|
by: Jimmy |
last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far:
<%
Dim oConn, oRS, randNum
Randomize()
randNum = (CInt(1000 * Rnd) + 1) * -1
Set oConn=Server.CreateObject("ADODB.Connection")
Set oRS=Server.CreateObject("ADODB.recordset")
oConn.Provider="Microsoft.Jet.OLEDB.4.0"
oConn.Open Server.MapPath("temp.mdb")
|
by: John Fairhurst |
last post by:
Hi,
The following code should select the specified number of records randomly
from the database
<%
....
query = "SELECT FROM "
Set RS = Server.CreateObject("ADODB.Recordset")
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |