Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exclude Query?

Status
Not open for further replies.

SecureNetworx

Technical User
Jun 3, 2005
10
US
I have columns in 3 tables I am working with; I am trying to exclude items in found in tblACCEPTED_SITES.UrlDomain but they show up in results. Any ideas what I am doing wrong?

SELECT tblLAN_OUT.MsgConndestdomain, tblLAN_OUT.MsgConndestport, COUNT(*) AS TotalHits
FROM tblLAN_OUT INNER JOIN tblHOSTS ON tblLAN_OUT.MsgConnsrcdomain = tblHOSTS.HostName
INNER JOIN tblACCEPTED_SITES ON tblLAN_OUT.MsgConndestdomain <> tblACCEPTED_SITES.UrlDomain
WHERE (tblHOSTS.HostOwner = 'Corporate') AND (tblLAN_OUT.MsgDate >= '2005-06-01')
GROUP BY tblLAN_OUT.MsgConndestdomain, tblLAN_OUT.MsgConndestport
ORDER BY COUNT(*) DESC
 
Hmmm .... Maybe ....
Code:
SELECT	tblLAN_OUT.MsgConndestdomain, 
	tblLAN_OUT.MsgConndestport, 
	COUNT(*) AS TotalHits

FROM		tblLAN_OUT 
INNER JOIN	tblHOSTS 
ON		tblLAN_OUT.MsgConnsrcdomain = tblHOSTS.HostName
WHERE   NOT EXISTS (	SELECT	* 
			FROM	tblACCEPTED_SITES
			WHERE	 MsgConndestdomain =  tblACCEPTED_SITES.UrlDomain)
AND		(tblHOSTS.HostOwner = 'Corporate') 
AND	(tblLAN_OUT.MsgDate >= '2005-06-01')
GROUP BY tblLAN_OUT.MsgConndestdomain,  tblLAN_OUT.MsgConndestport
ORDER BY COUNT(*) DESC
[code]

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top