
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2019 06:38 PM
Hi all.
slowly learning SQL, and I need a bit of assistance on this one query.
I want to query all Active directory users that don't have an asset of type 909 assigned to them. To do this, I have the following script, but it isn't working 😞
select username
from tblADusers
where not exists
(select tbladusers.username
,tblAssetUserRelations.AssetID
,tblassets.Assettype
from tblADusers
inner join tblassetuserrelations on tbladusers.username=tblassetuserrelations.username
inner join tblAssets on tblAssetuserrelations.AssetID=tblAssets.AssetID
where tblassets.assettype =909
)
If I run the sub Query, it pull in all AD users that do have asset type 909 assigned to them. so shouldn't it be as simple as running a query to pull the user that aren't in the sub query?
Any help will be appreciated.
Thanks in advance
,
Dan
slowly learning SQL, and I need a bit of assistance on this one query.
I want to query all Active directory users that don't have an asset of type 909 assigned to them. To do this, I have the following script, but it isn't working 😞
from tblADusers
where not exists
(select tbladusers.username
,tblAssetUserRelations.AssetID
,tblassets.Assettype
from tblADusers
inner join tblassetuserrelations on tbladusers.username=tblassetuserrelations.username
inner join tblAssets on tblAssetuserrelations.AssetID=tblAssets.AssetID
where tblassets.assettype =909
)
If I run the sub Query, it pull in all AD users that do have asset type 909 assigned to them. so shouldn't it be as simple as running a query to pull the user that aren't in the sub query?
Any help will be appreciated.
Thanks in advance

Dan
Labels:
- Labels:
-
Report Center
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2019 10:47 PM
Hello Dan,
I think this should do it for you.
SELECT tbladusers.username,
tblAssetUserRelations.AssetID,
tblassets.Assettype
FROM tblADusers
INNER JOIN tblassetuserrelations ON tbladusers.username=tblassetuserrelations.username
INNER JOIN tblAssets ON tblAssetuserrelations.AssetID=tblAssets.AssetID
WHERE tblassets.assettype <> 909
I think this should do it for you.
SELECT tbladusers.username,
tblAssetUserRelations.AssetID,
tblassets.Assettype
FROM tblADusers
INNER JOIN tblassetuserrelations ON tbladusers.username=tblassetuserrelations.username
INNER JOIN tblAssets ON tblAssetuserrelations.AssetID=tblAssets.AssetID
WHERE tblassets.assettype <> 909
