SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is there a built in method to make an array of unique numbers?

    For a simple search of a help desk application I've written, I'm querying text fields in two tables. One table is full of help desk calls (ids, where they're from, simple description, etc). The other table is full of messages that are related to a call (updates, reasons for closing, etc.) and has the call id as a foreign key. I've got some sql queries setup to get a list of all call ids that match a search term. Is there a built in way to sort the results to make sure they're unique? I know I could do it manually in a few lines of code but am always looking for the easiest way.

    Mark

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,289
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Can you combine all the queries into one and just use the DISTINCT parameter on the select statement?

    Otherwise you could always select your values into a string, then on subsequent queries do something like this:

    Code:
    strSQL = "SELECT call_id FROM TableName" & _
             " WHERE call_id not in (" & strCallIDs & ")"
    You would build the strCallIDs off the first query, then add onto it each additional query so at the end, the unique values would all be in the strCallIDs field, which you could then break out into an array if you'd like....
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the offered solution. This wasn't however what I was looking for. For the sake of doing it via other ways I tried looping through and using a dictionary ojbect. The code below seems like it should work, but doesn't. Any suggestions? It loads the first one into the dictionary ojbect and the remainder of the results are not added.

    [VBS]
    'in a loop where the ResultsObject has already been declared before the loop starts

    Dim bReturnValue
    bReturnValue = ResultsObject.Exists(Rs(0))
    if bReturnValue = true then
    Response.Write "<br>" & Rs(0) & " exists."
    else
    Response.Write "<br>" & Rs(0) & " is new to the dictionary object "
    ResultsObject.add Rs(0), Rs(0)
    end if
    [/VBS]

    Mark


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
  •