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

Help with query 1

Status
Not open for further replies.

mcf15

IS-IT--Management
Dec 5, 2012
4
US
Hello.

I have table that contains ID, hostname, level1, level2, level3. I need to get the IDs that exists only in level1="users", level2="home". I know I have 29379 unique IDs in /users/home and 26997 unique IDs in all other paths except for /users/home. But I need to know which unique IDs only reside in /users/home. I am complete stuck and needed this yesterday

Thanks!!!
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I've done a select distinct ID from tble where level1='users' and level2='home' to get the disctinct IDs for /users/home and select distinct ID from tble where level1 <>'users' and level2 <>'home' for distinct IDs outside of /users/home. That's it. NOt sure were to go from there. Not sure where to go from here. I need with the code. Thanks.
 
Code:
Select distinct 
 ID 
from 
 tble 
Where 
 level1='users' and level2 = 'home' and ID Not In (select ID from tble where level1 <>'users' and level2 <>'home')
 
where level1 <>'users' [!]OR[/!] level2 <>'home'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top