Forums

This topic is locked

Display Random Record from Recordset

Posted 24 Sep 2006 11:06:43
1
has voted
24 Sep 2006 11:06:43 Martin Cotterill posted:
I have a piece of SQL code that I cannot get to work in DW8.

The code is:
SELECT * FROM qryResales ORDER BY RND([ID]) LIMIT 3

From what I've read, this should work but as I know nothing about SQL, I don't know what's wrong.

I'm using the same recordset to display a filtered set of records already and I want to be able to display a completely random record from the same recordset elsewhere on the same page.

Can you help.

Many thanks in advance

Martin

Replies

Replied 27 Sep 2006 13:59:33
27 Sep 2006 13:59:33 Vince Baker replied:
what type of database are you using ? mysql, sql server, access etc?

Regards

Vince Baker
<strong>DMX Zone Manager</strong>

[VBScript | ASP | HTML | CSS | SQL | Oracle | AS400 | ERP Logic | Hosting]
Replied 27 Sep 2006 14:19:24
27 Sep 2006 14:19:24 Martin Cotterill replied:
Hi Vince

I've got it sorted now thanks. I found a great extension by Steven Jones here on DMXzone.

It can be found at www.dmxzone.com/showDetail.asp?TypeId=3&NewsId=3705

Regards

Martin
Replied 11 Aug 2007 21:50:32
11 Aug 2007 21:50:32 vojc Kutlacic replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi Vince

I've got it sorted now thanks. I found a great extension by Steven Jones here on DMXzone.

It can be found at www.dmxzone.com/showDetail.asp?TypeId=3&NewsId=3705

Regards

Martin
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Thanks for that fine extension. It work great if you want randomly display more than one record. I used Horizontal or vertical repeat region from Tom Muck. First it was a problem displaying record randomly because if you want display 2 or more random record at the time sometimes on load just display only one record so I look closer in code view and I notice if you just change value to 0 at bottom of random record code it's resolve problem.


<b>Original rendom record </b>

RS_totalrn = RS_totalrn - 1
If RS_totalrn &gt; 0 Then
Randomize
RS.Move Int((RS_totalrn + <font color=red>1</font id=red> * Rnd) <font color=red>&lt;-- change value to "RS_totalrn + 0" show always all desired record with repeat region</font id=red>
End If
End If
' all done; you should always check for an empty recordset before displaying data
%&gt;

Regards

Code Beginner Voice

Reply to this topic