Hi All
I use a MySQL DB with my ASP classic web app.
I've been asked if I can create a routine whereby I get a random number of
products (records) from the DB and display these on the site. Basically
every time a visitor hits the home page, they want the site to display a
random selection of say 6 products.
I have no problems getting the data and displaying it, my problem is
grabbing 6 random records efficiently.
My initial thought was bring back all of the records to a local array (like
I normally do) and then pick 6 random records in VBscript, but if a DB has
12,000 products this is a silly server hit to bring them all back just to
display 6 out of the 12,000.
The products table doesn't have an auto-number field, the unique-ness is
managed by the product's own unique stock code, but this isn't a sequential
number - its alphanum.
Any ideas on how I can get 6 randoms from the DB rather than bringing all
locally?
Thanks 3 2169
Laphan wrote:
Hi All
I use a MySQL DB with my ASP classic web app.
I've been asked if I can create a routine whereby I get a random
number of products (records) from the DB and display these on the
site. Basically every time a visitor hits the home page, they want
the site to display a random selection of say 6 products.
I have nothing to add to this: http://www.aspfaq.com/show.asp?id=2132
.... especially since I'm not familiar with the SQL dialect used by MySQL
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
On 21 Sep, 11:48, "Laphan" <ple...@dont.spam.comwrote:
Hi All
I use a MySQL DB with my ASP classic web app.
I've been asked if I can create a routine whereby I get a random number of
products (records) from the DB and display these on the site. *Basically
every time a visitor hits the home page, they want the site to display a
random selection of say 6 products.
I have no problems getting the data and displaying it, my problem is
grabbing 6 random records efficiently.
My initial thought was bring back all of the records to a local array (like
I normally do) and then pick 6 random records in VBscript, but if a DB has
12,000 products this is a silly server hit to bring them all back just to
display 6 out of the 12,000.
The products table doesn't have an auto-number field, the unique-ness is
managed by the product's own unique stock code, but this isn't a sequential
number - its alphanum.
Any ideas on how I can get 6 randoms from the DB rather than bringing all
locally?
Thanks
Ask this over on comp.databases.mysql.
Even better, just search its archives, you will find the answer to
this question, there.
"Laphan" <pl****@dont.spam.comwrote in message
news:eH**************@TK2MSFTNGP06.phx.gbl...
Hi All
I use a MySQL DB with my ASP classic web app.
I've been asked if I can create a routine whereby I get a random number of
products (records) from the DB and display these on the site. Basically
every time a visitor hits the home page, they want the site to display a
random selection of say 6 products.
I have no problems getting the data and displaying it, my problem is
grabbing 6 random records efficiently.
My initial thought was bring back all of the records to a local array
(like
I normally do) and then pick 6 random records in VBscript, but if a DB has
12,000 products this is a silly server hit to bring them all back just to
display 6 out of the 12,000.
The products table doesn't have an auto-number field, the unique-ness is
managed by the product's own unique stock code, but this isn't a
sequential
number - its alphanum.
Any ideas on how I can get 6 randoms from the DB rather than bringing all
locally?
Thanks
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...
|
by: Wim Roffil |
last post by:
Hi,
When I do a select with a limit I get always the same records. Usually this
is the desidered effect.
But now I want to do a random select. So every time I do a select I should
get a...
|
by: Russell Mangel |
last post by:
What would be the best way to parse this XML document?
I want to avoid using XMLDocument.
I don't know if I should use XMLTextReader, or Xpath classes.
There is only one element <MessageStore>...
|
by: yf |
last post by:
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is...
|
by: IceCube |
last post by:
Hello,
I would like to select/filter at random 30 records out of an
Access-table of 1500 records. I know the option "Top" which gives me
the possibility to see the 30 first records of the table...
| |
by: Greg Strong |
last post by:
Hello All,
Is it possible to create multiple random numbers in a query where
there are numerous records?
I've created a custom function. When I use it in a query it creates
the same random...
|
by: Cybertof |
last post by:
Hello,
Is there a simple way to read a random access file that has been created
with VB6 using direct writing to disk of Type....End Type structures ?
I have not found this possibility in C#.
...
|
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...
|
by: krypto.wizard |
last post by:
How to divide a number by 7 efficiently without using - or / operator.
We can use the bit operators. I was thinking about bit shift operator
but I don't know the correct answer.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
|
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...
|
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...
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |