Question [Urgent] Filtering and saving multiple records in multiple columns. (1 Viewer)

sx1

New member
Local time
Today, 17:06
Joined
Jun 2, 2009
Messages
4
Sorry about my first post being like this,but its sort of urgent. Having looked all over the internet this afternoon, I am quite tired and frustrated. And I need this for office tomm morning.:eek:

So i have a table with multiple columns. I think its better i explain by an example.

Eg:

C1 C2
1 X
1 X
2 X
2 Y
3 Y
4 Y
4 Y
5 X
5 X
5 X
.....
30,000

I need to filter C1 so that it will have both X & Y.(C2 is always X or Y). So in this case I need to get only 2 as it has both X & Y. So it shoudl appear like this:

C1 C2
2 X
2 Y

Then I need to export this to excel.

I tried to run the query WHERE C2="X" or C2="Y". But it hangs up,maybe bcos there are 4 more columns and I have filtered them, just can't filter this part.

Oh my knowledge level of access is average to slightly above avg.

Thank you very much for your help.
 

khawar

AWF VIP
Local time
Today, 11:06
Joined
Oct 28, 2006
Messages
870
Use This sql
Select C1,C2 from Yourtablename where c1=2
 

neileg

AWF VIP
Local time
Today, 08:06
Joined
Dec 4, 2002
Messages
5,975
Two queries:
Code:
SELECT DISTINCT MyTable.c1, MyTable.c2
FROM MyTable;
Code:
SELECT Query1.c1, Count(Query1.c2) AS CountOfc2
FROM Query1
GROUP BY Query1.c1
HAVING (((Count(Query1.c2))=2));
You could write this all in one query but two will work the same.
 

khawar

AWF VIP
Local time
Today, 11:06
Joined
Oct 28, 2006
Messages
870
Sorry i didnt read it properly Neileg's solution is perfect
 

sx1

New member
Local time
Today, 17:06
Joined
Jun 2, 2009
Messages
4
Thank You very much for your reply!
But a stupid question,what exactly is Query1 here?

Would it be the X & Y's? If so wouldn't there be a Query2 too?
 

sx1

New member
Local time
Today, 17:06
Joined
Jun 2, 2009
Messages
4
Sorry guys have to bump this. I need to get this thing done today.

Is query1 the name of the table or X/Y?
 

khawar

AWF VIP
Local time
Today, 11:06
Joined
Oct 28, 2006
Messages
870
two queries are suggested to you query1 will be the name of first query whatever name you give it replace query1 with that name
 

khawar

AWF VIP
Local time
Today, 11:06
Joined
Oct 28, 2006
Messages
870
Use the solution given to you by Neileg Paste the sql in the sql view of query
 

Users who are viewing this thread

Top Bottom