-
Displaying a random record from database
OK. I need whoever answers this to answer as if they were writing Database for Dummies! I have a music website whichI have my reviews in an Access database running it through ASP. I need to create another area on a page that can randomly display the records in the database. How do I code that and do I place it at the space in the page where I want the record to appear? I need the step by step version on this. I am a brand newbie!
-
In SQL server 2000 we can do this
select top 5 * from invsheet order by newID()
Any random number generation depends on the system clock. So use the date time function to generate a number and match your primary key column.
-
I don't understand you yet. I am brand new to ASP and one line of code doesn't mean much to me yet. I need a few steps on how to accomplish this within my webpage!
-
For example your table [Music] has columns and rows like this and
if you like to create a 5 random rows.
id MusicTitle Artist
--------------------------------------------------
1 All the things she said TATU
2 In Da Club
3 Pimp Juice
4 Not Gonna Get Us TATU
5 Bring Me To Life
6 Get Busy
7 I'm Glad
8 Can't Let You Go...Damn
9 Hot in here
10 Eminem
use this sql statement to return 5 rows in random. RND() function in MS-Access gets random values from System clock.
SELECT TOP 5 [MusicTitle], [Artist]
FROM MUSIC
order by Rnd([ID]);
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|