473,398 Members | 2,165 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,398 software developers and data experts.

Needing Help Creating a Union Query

I need to take four queries and make them into one table

This is what I get when I just do a simple select query.
Expand|Select|Wrap|Line Numbers
  1.  SELECT 
  2. Wholesale_Rank_qry_2.OMNI_Number, 
  3. Wholesale_Rank_qry_2.branch, 
  4. Wholesale_Rank_qry_2.branch_name, 
  5. Wholesale_Rank_qry_2.[Rank>], 
  6. Wholesale_Rank_qry_2.[0to5Rank], 
  7. Wholesale_Rank_qry_2.Star_Rating, 
  8.  
  9. Table_Rank_qry_2.[Rank>], 
  10. Purchase_Rank_qry_2.[Rank>], 
  11. CUSB_Rank_qry_2.[Rank>]
  12.  
  13. FROM CUSB_Rank_qry_2 RIGHT JOIN (Purchase_Rank_qry_2 RIGHT JOIN (Table_Rank_qry_2 RIGHT JOIN Wholesale_Rank_qry_2 ON Table_Rank_qry_2.OMNI_Number = Wholesale_Rank_qry_2.OMNI_Number) ON Purchase_Rank_qry_2.OMNI_Number = Wholesale_Rank_qry_2.OMNI_Number) ON CUSB_Rank_qry_2.OMNI_Number = Wholesale_Rank_qry_2.OMNI_Number;
I think this is what I want, but I’m receiving a error

[b]The number of columns in the two selected tables or queries of a union query do not match[/]

Expand|Select|Wrap|Line Numbers
  1. SELECT [OMNI_Number],[branch],[branch_name],[Rank>],[0to5Rank],[Star_Rating]
  2. FROM [Wholesale_Rank_qry_2]
  3.  
  4. UNION ALL SELECT [Rank>]
  5. FROM [Table_Rank_qry_2];
  6.  
  7. UNION ALL SELECT [Rank>]
  8. FROM [Purchase_Rank_qry_2];
This is my first time trying to put together a union query, and I have received a lot of help and training from this form, so I’m hoping someone will be about to help me with learn how to compile a union query.

Thanks for all your help and time

TCB
Jan 5 '11 #1
1 2070
Rabbit
12,516 Expert Mod 8TB
When you use a union query, the columns between the different SQL statements need to match. If I select column1 and column2 from one SQL statement, then I need two and only two columns in all subsequent SQL statements. If any one SQL statement has a different number of columns, then there will be an error.
Jan 5 '11 #2

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

Similar topics

3
by: Paradigm | last post by:
I am using Access 2K as a front end to a MYSQL database. I am trying to run a Union query on the MYSQL database. The query is (much simplified) SELECT as ID from faxdata UNION SELECT as ID ...
4
by: shaun palmer | last post by:
when or Where do you use a union query ? how can I wright sql, tblPopulation,* tblcustomer,* one to one with all the appropriate attributes(field). Your help would be greatly...
2
by: mattytee123 | last post by:
I have about 20 tables, of which I would like to do a union query and count of how many of each different code there is? The simplified verson of the table is structured like this. Code ...
4
by: spam | last post by:
If I run the following query in Access 2002 then I get the expected result: SELECT * FROM CSVImport UNION SELECT * FROM AssetTemp; I get the contents of both tables with no duplicates. If I...
5
by: BillCo | last post by:
I'm having a problem with a union query, two simple queries joined with a union statement. It's created in code based on parameters. Users were noticing some inconsistant data and when I analysed...
2
by: BerkshireGuy | last post by:
I have the following union query that works great, but I want to alter the query to only return True (-1) for the TEST column. Currently the test column DOES return 0 or -1. I just want the -1....
5
by: BillCo | last post by:
I've encountered a problem while using ADO to save query objects. Union queries created normally (via the interface) appear in adox catelog.procedures rather than catelog.views. This is reasonably...
8
by: kepston | last post by:
I have a situation where I need to record scrap quantities for parts that we sell and parts that are supplied, in a single table. I have a UNION query that combines the part numbers successfully,...
27
by: MLH | last post by:
How can I turn the following into a make-table query? SELECT & " " & AS Recipient FROM tblVehicleJobs INNER JOIN tblAddnlOwnrs ON tblVehicleJobs.VehicleJobID = tblAddnlOwnrs.VehicleJobID WHERE...
1
by: joshtate2001 | last post by:
I have been trying to figure out how to create a Union Query between two tables with different data with one field containing similiar data. I have 2 tables: NoteData & IndirectData The...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.