Print Page | Close Window

SQL Help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=14289
Printed Date: 01 April 2026 at 7:18am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: SQL Help
Posted By: Gullanian
Subject: SQL Help
Date Posted: 17 March 2005 at 6:02pm
Hi

Could anyone help me with a query?

tblUsers
  ID
  teamID

tblSectorUsers
  userID
  sectorID

I need to return a count(*) from tblSector users:

WHERE sectorID = x

And where the user whos user ID the record relates to has a teamID of y.

Any help appreciated!



Replies:
Posted By: dj air
Date Posted: 17 March 2005 at 6:07pm
"Select Count(SectorID) as Count FROM tblSectorUsers WHERE tblSectorUsers .SectorID = x AND (tblSectorUsers .UserID = tblUsers.TeamID AND tblUsers.teamID=y)"

i think that will help

not sure it'll work but thats the idea

you dont need the brackets


Posted By: Gullanian
Date Posted: 17 March 2005 at 6:40pm
Thanks for that, doesn't seem to work though.  I could go for the other option of opening all returned user records and checking the team but that would be resource intensive, or I could store teamID in sectorUsers but that'd just be data duplication.


Posted By: dj air
Date Posted: 17 March 2005 at 6:44pm
what problem was you getting .. you can try

"Select Count(SectorID) as Count FROM tblSectorUsers WHERE tblSectorUsers .SectorID = x AND tblUsers.teamID=y AND tblSectorUsers .UserID = tblUsers.ID;"

was it the ID value from users is the same as UserID in sectorUser, if so then the above should be ok


Posted By: Gullanian
Date Posted: 17 March 2005 at 7:02pm
Thanks for your help!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net