Missing a table join, try this:

SELECT DBO.SECURITYFILTERS.FILTERNAME,
DBO.SECURITYFILTERS.FILTERID,
DBO.SECUREDUSERS.NAME,
DBO.SECUREDUSERS.SUSERID
FROM DBO.SECURITYFILTERS,DBO.SECUREDUSERS,DBO.APPLIEDFILTERS
WHERE DBO.SECURITYFILTERS.FILTERID IN (
SELECT DBO.APPLIEDFILTERS.FILTERID
FROM DBO.APPLIEDFILTERS,DBO.SECURITYFILTERS
WHERE DBO.SECURITYFILTERS.FILTERID = DBO.APPLIEDFILTERS.FILTERID
AND DBO.SECURITYFILTERS.CUSTOMERID = @CUSTOMERID
)
AND (DBO.APPLIEDFILTERS.SUSERID = DBO.SECUREDUSERS.SUSERID AND DBO.SECURITYFILTERS.FILTERID = DBO.APPLIEDFILTERS.FILTERID)
AND DBO.SECURITYFILTERS.CUSTOMERID = @CUSTOMERID

> -----Original Message-----
> From: John mccosker [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 11, 2004 03:08 PM
> To: 'CF-Talk'
> Subject: sql question
>
> Hi,
>
> my head is twisted here trying to figures this out,
> I have three tables I am joining in a query like so,
>
> SELECT DBO.SECURITYFILTERS.FILTERNAME,
> DBO.SECURITYFILTERS.FILTERID,
> DBO.SECUREDUSERS.NAME,
> DBO.SECUREDUSERS.SUSERID
> FROM DBO.SECURITYFILTERS,DBO.SECUREDUSERS,DBO.APPLIEDFILTERS
> WHERE DBO.SECURITYFILTERS.FILTERID IN (
> SELECT DBO.APPLIEDFILTERS.FILTERID
> FROM DBO.APPLIEDFILTERS,DBO.SECURITYFILTERS
> WHERE DBO.SECURITYFILTERS.FILTERID = DBO.APPLIEDFILTERS.FILTERID
> AND DBO.SECURITYFILTERS.CUSTOMERID = @CUSTOMERID
> )
> AND DBO.APPLIEDFILTERS.SUSERID = DBO.SECUREDUSERS.SUSERID
> AND DBO.SECURITYFILTERS.CUSTOMERID = @CUSTOMERID
>
> what I am expecting is,
>
> fa  23          unit1
> fb  24          unit2
> fc  23          unit3
>
> but I am getting is this,
>
> fa  23          unit1
> fb  24          unit2
> fc  23          unit3
> fa  24          unit1
> fb  23          unit2
> fc  24          unit3
>
> if I have not supplied enough information I apologise
> its a real simple join problem, but I just can't see it.
>
> john.
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to