Getting recordcount from resultset of 'union' query

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

  1. #1

    Default Getting recordcount from resultset of 'union' query

    Hi,

    I need to find out the number of records in the resultset of a union of 2 queries.

    E.g.

    "select ID from Pages where numPageCatID = " & p_iCatID & _
    " and ID not in (1,2,3,4)" & _
    " union" & _
    " select ID from Pages" & _
    " inner join UserCatPages on UserCatPages.numPageID = Pages.ID" & _
    " where UserCatPages.numUserCatID in (12,3)"

    I am now building a recordset and using l_oRs.GetRows() to get the number of records, and that works okay.

    But is it possible to somehow use the Count() function in the SQL query above?

    --
    Marja Ribbers-de Vroed

    Internet:
    - [url]www.webwaresystems.nl[/url]
    - [url]www.clubwebware.nl[/url]
    - [url]www.flevooware.nl/dreamweaver[/url]


    Marja Ribbers Guest

  2. Similar Questions and Discussions

    1. CFC Query not returning recordcount
      I wrote a CFC that performs a simple query. After the CFC runs the query I try to check for the recordcount in the calling template and get the...
    2. return query resultset from custom tag
      Hi, How to return an entire query resultset from custom tag to the calling page ? Thanks for your help. vmrao
    3. ORDER BY in UNION query
      Hi, I need to use ORDER BY clause in a UNION query and the Order BY columns are not included in the SELECT statement. I tried like this (select...
    4. Sorting With a UNION Query?
      Hey all, I'm working with SQL server 2000 (upsized from MS Access 2000) and I've been able to reconcile all my SQL differences but one. I build a...
    5. UNION QUERY
      I've just installed version 4 of MySql and understand this may be a question regarding my syntax, not PHP, but I'm receiving errors from the...
  3. #2

    Default Re: Getting recordcount from resultset of 'union' query

    Marja Ribbers wrote:
    > Hi,
    >
    > I need to find out the number of records in the resultset of a union
    > of 2 queries.
    >
    > E.g.
    >
    > "select ID from Pages where numPageCatID = " & p_iCatID & _
    > " and ID not in (1,2,3,4)" & _
    > " union" & _
    > " select ID from Pages" & _
    > " inner join UserCatPages on UserCatPages.numPageID = Pages.ID" & _
    > " where UserCatPages.numUserCatID in (12,3)"
    >
    > I am now building a recordset and using l_oRs.GetRows() to get the
    > number of records, and that works okay.
    >
    > But is it possible to somehow use the Count() function in the SQL
    > query above?
    Marja,

    Are you just trying to count the total records? Or are you trying to count
    something more specific within the recordset? If just the total records,
    use the UBound function (+1) once the records are brought into an array from
    the GetRows function.

    --
    kindler chase
    [url]http://www.ncubed.com[/url]
    Home of SuperInvoice: The Online Invoicing Application.
    Organize your billing process and impress your clients.

    [url]news://news.ncubed.com/support[/url]
    n3 Support Group


    Kindler Chase Guest

  4. #3

    Default Re: Getting recordcount from resultset of 'union' query

    Hi Kindler,

    Yes, as I already mentioned I am currently using the GetRows() method (with the UBound() function).
    But I was wondering if it could be done otherwise.

    --
    Marja Ribbers-de Vroed

    Internet:
    - [url]www.webwaresystems.nl[/url]
    - [url]www.clubwebware.nl[/url]
    - [url]www.flevooware.nl/dreamweaver[/url]


    "Kindler Chase" <weaver@DELETEME_roubaixinteractive.com> wrote in message news:d5iv64$gf6$1@forums.macromedia.com...
    > Marja Ribbers wrote:
    >> Hi,
    >>
    >> I need to find out the number of records in the resultset of a union
    >> of 2 queries.
    >>
    >> E.g.
    >>
    >> "select ID from Pages where numPageCatID = " & p_iCatID & _
    >> " and ID not in (1,2,3,4)" & _
    >> " union" & _
    >> " select ID from Pages" & _
    >> " inner join UserCatPages on UserCatPages.numPageID = Pages.ID" & _
    >> " where UserCatPages.numUserCatID in (12,3)"
    >>
    >> I am now building a recordset and using l_oRs.GetRows() to get the
    >> number of records, and that works okay.
    >>
    >> But is it possible to somehow use the Count() function in the SQL
    >> query above?
    >
    > Marja,
    >
    > Are you just trying to count the total records? Or are you trying to count
    > something more specific within the recordset? If just the total records,
    > use the UBound function (+1) once the records are brought into an array from
    > the GetRows function.
    >
    > --
    > kindler chase
    > [url]http://www.ncubed.com[/url]
    > Home of SuperInvoice: The Online Invoicing Application.
    > Organize your billing process and impress your clients.
    >
    > [url]news://news.ncubed.com/support[/url]
    > n3 Support Group
    >
    >
    Marja Ribbers Guest

  5. #4

    Default Re: Getting recordcount from resultset of 'union' query

    Marja Ribbers wrote:
    > Hi Kindler,
    >
    > Yes, as I already mentioned I am currently using the GetRows() method
    > (with the UBound() function).
    > But I was wondering if it could be done otherwise.
    Yes, it can be done. However, you'd have to create a sub-query and would be
    less efficient than using the UBound function.

    --
    kindler chase
    [url]http://www.ncubed.com[/url]
    Home of SuperInvoice: The Online Invoicing Application.
    Organize your billing process and impress your clients.

    [url]news://news.ncubed.com/support[/url]
    n3 Support Group


    Kindler Chase 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