Exclude sime recirds from query result (1 Viewer)

LjushaMisha

Registered User.
Local time
Today, 01:25
Joined
Mar 10, 2017
Messages
69

exclude some records from query​

Hi.
I have a table called "tblParts". Some records from this table are as follows.
Id Name Level IdSuperior
04 Bad 0 Null
17 Wardrobe 0 Null
15 Shelf 3 10
19 Side Board 1 22
20 Bottom 2 12
19 Side Board 0 Null

Point: Id 19 is correctly entered twice.
Question: How to "make" query where ALL id's where level is 0 and id superior is Null are NOT in the result of query? It means all entries of product Id 19 should be excluded from query result if one of entries has level 0 AND idSuperior Null.
 
Have you tried it yet:
Code:
SELECT tblParts.*
FROM tblParts
WHERE ID NOT IN (SELECT tblParts.ID
FROM tblParts WHERE 
(DCOUNT("1","TBLPARTS","ID=" & [ID] & " AND ISNULL(IDSUPERIOR)=TRUE")>0 AND  
DCOUNT("1","TBLPARTS","ID=" & [ID] & " AND ISNULL(IDSUPERIOR)=FALSE")>0));

result:
IDNameLevelIDSuperior
4Bad0
17Wardrobe0
15Shelf310
20Bottom212
 

Users who are viewing this thread

Back
Top Bottom