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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Two Users Where Column Equals Two Different Varaibles 1

Status
Not open for further replies.

jsnull

IS-IT--Management
Feb 19, 2002
99
US

Trying to figure out how to get the usernames of users who are flagged in two networks.

For example: my table is laid out as id, username, network.

User jim can be in network ABC and in network XYZ thus there would be a record for each

DATA EXAMPLE
id, username, network
1, jim, ABC
2, jim, XYZ
4, tom, ABC
5, rick, ABC
7, mary, XYZ
8, jima, ABC
9, roberta, XYZ

I am trying to create a sql where I get all users who are in networks ABC and XYZ exclusive of all other users, in this case it would return just "jim".

I've failed so far. Help very much appreciated.


Jim Null

 
Code:
SELECT username
  FROM daTable
 WHERE network IN ( 'ABC' , 'XYZ' )
GROUP
    BY username
HAVING COUNT(*) = 2

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top