473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with UNION query please?

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
5 1616
Rabbit
12,516 Expert Mod 8TB
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
8,834 Expert 8TB
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
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
8,834 Expert 8TB
Hiya...thanks.
Think this was what i needed!

Cheers!
Glad to help.
Feb 22 '07 #5
NeoPa
32,556 Expert Mod 16PB
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

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

Similar topics

4
by: techquest | last post by:
got slightly similar table. #Temp Table: name,name1,name2,exam,score A,A1,A21, A,A1,A21,math100,88 A,A1,A21,math101,56 A,A1,A21, A,A1,A21,math102,67 A,A1,A21, A,A1,A21,math104,45
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
6
by: mo | last post by:
I need to bring the ssn's into UniqueSups (supervisors) from tblNonNormalized. My inherited DB is not normalized and I find it extremely irritating due to the workarounds needed. I created...
15
by: plaztik8 | last post by:
Hello, Can someone please help me with a query? The table looks like this: BookedRooms =========== CustomerID RoomID BookDateID
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
4
by: Missy | last post by:
We’ve recently upgraded our computer system to XP. My union query (which was working perfectly for years) now returns hieroglyphics instead of invoice numbers. When I run the 2 queries...
4
by: Mark | last post by:
Hi all, I am currently in the design stages of a database for work. I have come up with a way to get informaion I need using a union query but was wandering what effects this will have on...
5
by: Lyn | last post by:
This one is difficult to explain, so I will cut it down to the basics. I have a major table 'tblA' which has an autonum field 'ID-A' as primary key (of no significance to users). 'tblA' contains...
4
by: bhargav.desai | last post by:
Hello Gurus, I need help! I have two table, tblCurrent and tblPrevious. What I want to join the tables, and create a new table that have matching records from both the tables, plus this new...
6
by: das | last post by:
Hello all, I have a table with thousands of rows and is in this format: id col1 col2 col3 col4 --- ------ ----- ------ ------ 1 nm 78 xyz pir 2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.