By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 3,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

Help with UNION query please?

P: 6
Hiya,

I have this problem that i need some terrible help with.
I have 2 nearly identical tables with similar fields that i would like to combine into 1 single query. The tables look like below:

Expand|Select|Wrap|Line Numbers
  1. tblCCA_1
  2. CCA_NAME
  3. CCA_GROUPING
Expand|Select|Wrap|Line Numbers
  1. tblCCA_2
  2. CCA_NAME
  3. CCA_GROUPING
My database is used in a school to keep track of student's club memberships.
tblCCA_1 basically holds the names of students that have that particular club as their main CCA (Co-Curricular Activity).
tblCCA_2 basically holds those students who join that particular club as a Second CCA.
So what i want to do is to find the total membership strength of a particular club by joining these 2 table.

Please help!!
Cheers!
Feb 21 '07 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,341
I'm not sure what you're trying to accomplish. Can you go into more detail about the fields in the tables and what information they hold? And what end result are you looking for?
Feb 21 '07 #2

ADezii
Expert 5K+
P: 8,616
Hiya,

I have this problem that i need some terrible help with.
I have 2 nearly identical tables with similar fields that i would like to combine into 1 single query. The tables look like below:

Expand|Select|Wrap|Line Numbers
  1. tblCCA_1
  2. CCA_NAME
  3. CCA_GROUPING
Expand|Select|Wrap|Line Numbers
  1. tblCCA_2
  2. CCA_NAME
  3. CCA_GROUPING
My database is used in a school to keep track of student's club memberships.
tblCCA_1 basically holds the names of students that have that particular club as their main CCA (Co-Curricular Activity).
tblCCA_2 basically holds those students who join that particular club as a Second CCA.
So what i want to do is to find the total membership strength of a particular club by joining these 2 table.

Please help!!
Cheers!
I do not think that you will need a Union Query to accomplish what you are requesting, Assuming [CCA_GROUPING] is the Club Name, the following code will return the total membership strength for the Baseball Club, both as a Main and Secondary Co-Curricular Activity. Is this what you were looking for?
Expand|Select|Wrap|Line Numbers
  1. DCount("*", "tblCCA_1","[CCA_GROUPING]='" & "Baseball" & "'") + _
  2. DCount("*", "tblCCA_2","[CCA_GROUPING]='" & "Baseball" & "'")
Feb 21 '07 #3

P: 6
I do not think that you will need a Union Query to accomplish what you are requesting, Assuming [CCA_GROUPING] is the Club Name, the following code will return the total membership strength for the Baseball Club, both as a Main and Secondary Co-Curricular Activity. Is this what you were looking for?
Expand|Select|Wrap|Line Numbers
  1. DCount("*", "tblCCA_1","[CCA_GROUPING]='" & "Baseball" & "'") + _
  2. DCount("*", "tblCCA_2","[CCA_GROUPING]='" & "Baseball" & "'")
Hiya...thanks.
Think this was what i needed!

Cheers!
Feb 22 '07 #4

ADezii
Expert 5K+
P: 8,616
Hiya...thanks.
Think this was what i needed!

Cheers!
Glad to help.
Feb 22 '07 #5

NeoPa
Expert Mod 15k+
P: 31,307
For anyone else searching for help on UNION queries there is a Tutorial (Basic SQL Syntax for Access Queries) including this info.

While I'm here, I may as well recommend the Normalisation idea where you would store both sets of data in the same table anyway (Normalisation and Table structures).
Feb 23 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.