Thanks! 

You know...I actually was thinking about that and figured...it might be the
weenie way out, but it would be easier to get the logic worked out.
HA...nice to see I'm not TOO weenie here! Although I may have messed up that
code, too...so thanks so much for providing it. 

Back to the SQL drawing board!

Dian ~



-----Original Message-----
From: Shawn K. Hall [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 12, 2005 9:38 PM
To: [email protected]
Subject: RE: [ASP] 3rd table query, getting double returns?


Hi Dian,

> Further to the item below...I just messed with the query in 
> the ASA query editor and realized I'm getting TWO client
> lists, due to the fact that each (of this sample data)
> happens to have two pets. So it is pulling two client names
> due to the fact that there are two patient matches in that
> 3rd matching table.
> 
> So it's saying...here's one match, here's another, due to
> the two clientIDs in the OWNER table...one for the owner's
> dog, one for the owner's cat.

What I would recommend is enumerating a simple join for the
owner/client tables and then calling a function to enumerate
patients based on the clientid returned in the initial join in order
to ensure that you don't redisplay duplicate data. This is usually
done something like this (pseudo/vaporcode):

'// ======================================================== 
...
  sSql = "select * from pets where lastname=" & sLastName & ";"
' call YOUR library function that returns a 2-d array from sql
  dClients = arrayFromSql(sSql)
  lClients = UBound( dClients, 2 )
  for lrClient = 0 To lClients
  ' clientdata goes here
    response.write "<div class=""client"">"
    lClientID = dClients(0, lrClient) '1st field is clientid
    sClient   = dClients(1, lrClient) '2nd field is clientname
    response.write "<p>" & sClient & "</p>"
    response.write PetInfo( lClientID )
    response.write "</div>"
  next
...
'[support]
  function PetInfo ( lClientID )
    dim sSql, sBuild, dPets, lPets
    sSql = "select * from pets where clientid=" & lClientID & ";"
  ' call YOUR library function that returns a 2-d array from sql
    dPets = arrayFromSql(sSql)
  ' enumerate pets
    lPets = UBound( dPets, 2 )
    for lrClient = 0 To lPets
    ' petdata goes here
      lPetID = dClients(0, lrClient) '1st field is petid
      sPet = dClients(1, lrClient) '2nd field is petname
      sBuild = sBuild & "<div class=""pet"" id=""pet" & lPetID &
""">"
      sBuild = sBuild & "<p>" & sPet & "</p>"
      sBuild = sBuild & "</div>"
    next
  ' return
    PetInfo = sBuild
  end function
'// ======================================================== 

Of course, depending on how convoluted the table linking is, you
might want to make three steps out of it - get the owner, link up to
the client, then link to the patient - in three distinct queries.

Regards,

Shawn K. Hall
http://12PointDesign.com/
http://ReliableAnswers.com/




---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [email protected]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links



 




-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005
 

-- 
This email scanned and certified clean by AVG!
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005
 



---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [email protected]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to