Professional Web Applications Themes

filtering a second rs with the filtered results of a first rs - Dreamweaver AppDev

I am having trouble doing this. I want to use a filtered recordset to filter a second recordset. For example, the results of the first rs are Institution ID numbers. I want to use all the returned records to filter a second recordset which gets values from a different table but contains the Institution ID field as well. Thanks for any help....

  1. #1

    Default filtering a second rs with the filtered results of a first rs

    I am having trouble doing this. I want to use a filtered recordset to filter
    a second recordset. For example, the results of the first rs are Institution
    ID numbers. I want to use all the returned records to filter a second
    recordset which gets values from a different table but contains the
    Institution ID field as well.

    Thanks for any help.


    Zachariah Crow Guest

  2. #2

    Default Re: filtering a second rs with the filtered results of a first rs

    One way to do it would be to put all of the IDs returned from the first
    recordset into an array, and then you could use the IN clause to filter your
    second recordset.

    Hypothetical Example:

    set rs = createobject("adodb.recordset")
    rs.open "select ID, Institution from tbl_Institutions" , cn

    if not rs.eof then
    dim arr_ids
    i = 0
    while not rs.eof
    if i = 0 then
    arr_ids = rs("ID")
    else
    arr_ids = arr_ids & "," & rs("ID")
    end if
    i = i + 1
    rs.movenext()
    wend
    end if

    'now all of the ids are in an array and you can use it to filter your
    second recordset

    set rs2 = createobject("adodb.recordset")
    rs2.open "select something from other_table where foreign_key in (" &
    arr_ids & ")" , cn

    end if

    I haven't tested this, but it should get you going on the right path.
    bT

    "Zachariah Crow" <zcrowshaw.ca> wrote in message
    news:d5qt5q$du2$1forums.macromedia.com...
    >I am having trouble doing this. I want to use a filtered recordset to
    >filter a second recordset. For example, the results of the first rs are
    >Institution ID numbers. I want to use all the returned records to filter a
    >second recordset which gets values from a different table but contains the
    >Institution ID field as well.
    >
    > Thanks for any help.
    >

    Brandon Taylor Guest

  3. #3

    Default Re: filtering a second rs with the filtered results of a first rs

    Hi Brandon and thanks for the help on this.

    I just can't seem to get the array to work however. If I try and display the
    array it is blank when I know there should be returned records.


    "Brandon Taylor" <btbtaylordesign.com> wrote in message
    news:d5qvel$haq$1forums.macromedia.com...
    > One way to do it would be to put all of the IDs returned from the first
    > recordset into an array, and then you could use the IN clause to filter
    > your second recordset.
    >
    > Hypothetical Example:
    >
    > set rs = createobject("adodb.recordset")
    > rs.open "select ID, Institution from tbl_Institutions" , cn
    >
    > if not rs.eof then
    > dim arr_ids
    > i = 0
    > while not rs.eof
    > if i = 0 then
    > arr_ids = rs("ID")
    > else
    > arr_ids = arr_ids & "," & rs("ID")
    > end if
    > i = i + 1
    > rs.movenext()
    > wend
    > end if
    >
    > 'now all of the ids are in an array and you can use it to filter your
    > second recordset
    >
    > set rs2 = createobject("adodb.recordset")
    > rs2.open "select something from other_table where foreign_key in (" &
    > arr_ids & ")" , cn
    >
    > end if
    >
    > I haven't tested this, but it should get you going on the right path.
    > bT
    >
    > "Zachariah Crow" <zcrowshaw.ca> wrote in message
    > news:d5qt5q$du2$1forums.macromedia.com...
    >>I am having trouble doing this. I want to use a filtered recordset to
    >>filter a second recordset. For example, the results of the first rs are
    >>Institution ID numbers. I want to use all the returned records to filter a
    >>second recordset which gets values from a different table but contains the
    >>Institution ID field as well.
    >>
    >> Thanks for any help.
    >>
    >
    >

    Zachariah Crow Guest

  4. #4

    Default Re: filtering a second rs with the filtered results of a first rs

    Hmm, that's weird. Email me your page as a zip to [email]btbtaylordesign.com[/email] and
    I'll take a look at it for you.

    bT

    "Zachariah Crow" <zcrowshaw.ca> wrote in message
    news:d5r1c8$kdk$1forums.macromedia.com...
    > Hi Brandon and thanks for the help on this.
    >
    > I just can't seem to get the array to work however. If I try and display
    > the array it is blank when I know there should be returned records.
    >
    >
    > "Brandon Taylor" <btbtaylordesign.com> wrote in message
    > news:d5qvel$haq$1forums.macromedia.com...
    >> One way to do it would be to put all of the IDs returned from the first
    >> recordset into an array, and then you could use the IN clause to filter
    >> your second recordset.
    >>
    >> Hypothetical Example:
    >>
    >> set rs = createobject("adodb.recordset")
    >> rs.open "select ID, Institution from tbl_Institutions" , cn
    >>
    >> if not rs.eof then
    >> dim arr_ids
    >> i = 0
    >> while not rs.eof
    >> if i = 0 then
    >> arr_ids = rs("ID")
    >> else
    >> arr_ids = arr_ids & "," & rs("ID")
    >> end if
    >> i = i + 1
    >> rs.movenext()
    >> wend
    >> end if
    >>
    >> 'now all of the ids are in an array and you can use it to filter your
    >> second recordset
    >>
    >> set rs2 = createobject("adodb.recordset")
    >> rs2.open "select something from other_table where foreign_key in (" &
    >> arr_ids & ")" , cn
    >>
    >> end if
    >>
    >> I haven't tested this, but it should get you going on the right path.
    >> bT
    >>
    >> "Zachariah Crow" <zcrowshaw.ca> wrote in message
    >> news:d5qt5q$du2$1forums.macromedia.com...
    >>>I am having trouble doing this. I want to use a filtered recordset to
    >>>filter a second recordset. For example, the results of the first rs are
    >>>Institution ID numbers. I want to use all the returned records to filter
    >>>a second recordset which gets values from a different table but contains
    >>>the Institution ID field as well.
    >>>
    >>> Thanks for any help.
    >>>
    >>
    >>
    >
    >

    Brandon Taylor Guest

Similar Threads

  1. First item from form to filtered datagrid not displayingimmediately
    By EvolvedDSM in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: May 22nd, 02:13 PM
  2. high-frequencies getting filtered
    By trehug in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: March 6th, 10:22 AM
  3. Filtering dataGrid results
    By Kwooda in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: May 6th, 04:19 AM
  4. Filtering query results
    By DuLaus in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: April 7th, 08:30 PM
  5. Mail() Script Getting Filtered As Spam
    By kpar in forum PHP Development
    Replies: 3
    Last Post: December 8th, 10:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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