Hi John,
In your statements below, did you mean to enter [Column 2] instead of 1. All
of the K's and W's are in column 2 so not sure how this works. Either way, I
did try it both ways and I didn't get any results. I am mainly looking at the
second statement for now. This is the one that is causing me the most
headaches. I have copy clipped the SQL statement to show you how it was
written and column 1 has been replaced by Skid Mix and column 2 would be
replaced by PO if I had left it.
SELECT qrySeneca_Skid_Sorting_Mixed.[Skid Mix]
FROM qrySeneca_Skid_Sorting_Mixed
WHERE (((Exists (Select * FROM [qrySeneca_Skid_Sorting_Mixed] as Temp WHERE
[Skid Mix] LIKE "K*"))<>False) AND ((Exists (Select * FROM
[qrySeneca_Skid_Sorting_Mixed] as Temp WHERE [Skid Mix] Like "W*"))<>False)
AND NOT ((Exists (Select * FROM [qrySeneca_Skid_Sorting_Mixed] as Temp Where
[Skid Mix] NOT LIKE "K*" and [Skid Mix] NOT LIKE "W*"))=False));
This is how it appears after I typed it in the way you have it below. What I
do want to see in this query are only the skid mixes that have a K and a W
value. I don't want to see any other skids that may contain just K's or W's.
Thanks
Darren
John Spencer said:
I think you want just those column 1 values that have a column 2 value that
begins with K and has no column 2 values that begin with any other letter.
SELECT Distinct [Column 1]
FROM [TheTable]
WHERE [Column 2] Like "K*"
AND NOT EXISTS
(SELECT *
FROM [TheTable] as Temp
WHERE [Column 1] NOT LIKE "K*")
Next you want records have a column 2 with a K value and a W value. You did
not say if you want that limited to only K and W and if they have a Z that is
ok.
SELECT [Column 1]
FROM [TheTable]
WHERE Exists
(SELECT *
FROM [TheTable] as Temp
WHERE [Column 1] LIKE "K*")
AND Exists
(SELECT *
FROM [TheTable] as Temp
WHERE [Column 1] LIKE "W*")
AND NOT Exists
(SELECT *
FROM [TheTable] as Temp
WHERE [Column 1] Not LIKE "K*"
AND [Column 1] Not Like "W*")
Your third query should be similar and I leave it to you to figure it out.
This WILL be SLOW if you have any large set of records. If you do have large
sets of records there are alternative techniques that could be used that may
be faster.
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
ddoblank wrote:
I have to columns that I want to try and filter out at the same time. Not
really sure if this is possible.
example
Column 1 Column 2
770/005 K01001
770/005 K01002
770/005 K01003
770/006 W01001
770/006 K01004
770/007 Z01001
770/007 W01002
What I want to do is pull all of the column 1's that have only K values,
then pull column 1's that have mixed k,w values and finally column 1's with
mixed w,z values. I have tried to think off an IIF statement but couldn't
quite get my head around it. I can't see how a Like or Not Like statement
will work either.
.