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

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

  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. Similar Questions and Discussions

    1. First item from form to filtered datagrid not displayingimmediately
      In my main application, I've got two components: One is a datagrid and the other is a form. The datagrid has a filterFunction on it's dataprovider...
    2. high-frequencies getting filtered
      Hi all, not sure where to ask this, I hope someone can give me some insight. When I go to a website that allows me to stream audio and video from...
    3. Filtering dataGrid results
      I have spent the day in the help files, trying to understand how I can filter a dataset. I have a dataGrid whose dataProvider is bound to an...
    4. Filtering query results
      Hi, How do I filter result output data based on WHERE clauses in a query like below. This query should output based upon #FORM.city# OR #URL.city#...
    5. Mail() Script Getting Filtered As Spam
      Using PHP 4, I developed a form to be submitted and emailed. Our PHP server is internal. Our company uses Yahoo's Mailsender.net for email. The...
  3. #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" <zcrow@shaw.ca> wrote in message
    news:d5qt5q$du2$1@forums.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

  4. #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" <bt@btaylordesign.com> wrote in message
    news:d5qvel$haq$1@forums.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" <zcrow@shaw.ca> wrote in message
    > news:d5qt5q$du2$1@forums.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

  5. #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]bt@btaylordesign.com[/email] and
    I'll take a look at it for you.

    bT

    "Zachariah Crow" <zcrow@shaw.ca> wrote in message
    news:d5r1c8$kdk$1@forums.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" <bt@btaylordesign.com> wrote in message
    > news:d5qvel$haq$1@forums.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" <zcrow@shaw.ca> wrote in message
    >> news:d5qt5q$du2$1@forums.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

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