Randomly Ordered Recordset

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Randomly Ordered Recordset

    Hello everyone,

    I'm using MX04, Access, VB Script.

    I need to select 10 unique records and randomly order them. I've done quite
    a bit of searching online to find an example, but can't seem to find quite
    what I'm looking for.

    Does anyone have a good example they can point me to?

    Many thanks in advance,
    Brandon


    Brandon Taylor Guest

  2. Similar Questions and Discussions

    1. Convert Shared Object properties into ordered array
      I need to put the shared object data (that contains the client names) into an ordered array. The following is NOT useful: for (var i in...
    2. Ordered list in cfoutput?
      I'm trying to create an ordered list that will display a list of profiles numerically. I've tried placing the OL both outside the cfoutput...
    3. Make ordered list
      Hello, I have several list items for which I'd like to make an ordered list using Roman Large numbers (I,II,III,)... Each time I press the ordered...
    4. How to sort 2 arrays and keep indices ordered?
      Hi all, Is there an easy way to sort 2 arrays and keep the relating indices together. for instance I have an array of times, and an array of...
    5. selecting ordered groups out of a table
      Rainer Gauweiler wrote: with recent_orders as ( select customer, invoice-nr, date, row_number() over (partition by customer, order by date...
  3. #2

    Default Re: Randomly Ordered Recordset

    Whenever you have a challenge like this, break it down into its smallest
    components...

    As I see it, here's what you need to do.
    1) Find out your total number of records
    2) Randomly pull the first record item
    3) Select a random record again, this time checking to make sure that
    you don't already have that record
    4) Do this until you get 10 unique records...

    If you're in ASP, check out 4guysfromrolla website for code to put the
    entire contents of your recordset into an array, that way you make 1
    trip to the database, sever that connection THEN do the random thing. I
    believe it's called Getrows.

    Good luck.

    jv Guest

  4. #3

    Default Re: Randomly Ordered Recordset

    as jv pointed out, you can store your recordset in an array with GetRows:

    rsArray = rs.GetRows()

    then sort the array randomly & choose the first/last/... 10 elements

    if your table is too big & you're worried about the array size or
    sorting time, you can specify the number of records to retrieve:

    rsArray = rs.GetRows(100, 20) ' 100 records beginning from 20

    HTH,

    manuel

    Brandon Taylor wrote:
    > Hello everyone,
    >
    > I'm using MX04, Access, VB Script.
    >
    > I need to select 10 unique records and randomly order them. I've done quite
    > a bit of searching online to find an example, but can't seem to find quite
    > what I'm looking for.
    >
    > Does anyone have a good example they can point me to?
    >
    > Many thanks in advance,
    > Brandon
    >
    >
    Manuel Socarras Guest

  5. #4

    Default Re: Randomly Ordered Recordset

    Thanks guys. I check out the 4 Guys method.

    Brandon

    "Manuel Socarras" <msoc**no-spam**@airtel.net> wrote in message
    news:cvj60s$8g9$1@forums.macromedia.com...
    > as jv pointed out, you can store your recordset in an array with GetRows:
    >
    > rsArray = rs.GetRows()
    >
    > then sort the array randomly & choose the first/last/... 10 elements
    >
    > if your table is too big & you're worried about the array size or sorting
    > time, you can specify the number of records to retrieve:
    >
    > rsArray = rs.GetRows(100, 20) ' 100 records beginning from 20
    >
    > HTH,
    >
    > manuel
    >
    > Brandon Taylor wrote:
    >
    >> Hello everyone,
    >>
    >> I'm using MX04, Access, VB Script.
    >>
    >> I need to select 10 unique records and randomly order them. I've done
    >> quite a bit of searching online to find an example, but can't seem to
    >> find quite what I'm looking for.
    >>
    >> Does anyone have a good example they can point me to?
    >>
    >> Many thanks in advance,
    >> Brandon

    Brandon Taylor Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139