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

Union Query Problem

I need to make a union query that returns the results of 2 queries
without combining any fields.
Let me give you an example

Query1
Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 10 0 Electrical Eng.

Query2
Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 0 10 Mech Eng

I want the query to show both records but it tries to put them
together if there is no budget. The query returns the following:

Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 10 10 Mech Eng

Obviously this doesn't work because the budget was for a Elec Eng and
not a Mech eng.
Any help would be great...
Here is my SQL code...

SELECT [workorder],[sequence],[budget],[sumofhrs],[jobcode],[link],[sequence
description],[job category2],[employee category]

from [allbudgetlabor]

UNION select ALL [wonumber],[sequence],[budget],[sumofhrs],[job],[link],[sequence
description],[job category2],[employee category]

from [alllaborbudget];
Nov 12 '05 #1
2 1854
"turtle" <ko****@vistacontrols.com> wrote in message
news:58**************************@posting.google.c om...
I need to make a union query that returns the results of 2 queries
without combining any fields.
Let me give you an example

Query1
Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 10 0 Electrical Eng.

Query2
Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 0 10 Mech Eng

I want the query to show both records but it tries to put them
together if there is no budget. The query returns the following:

Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 10 10 Mech Eng

Obviously this doesn't work because the budget was for a Elec Eng and
not a Mech eng.
Any help would be great...
Here is my SQL code...

try UNION ALL instead of UNION

Nov 12 '05 #2
John,
Thanks, but I did try union all and did not get all the records... it
seemed to combine the data.

"John Winterbottom" <as******@hotmail.com> wrote in message news:<2h************@uni-berlin.de>...
"turtle" <ko****@vistacontrols.com> wrote in message
news:58**************************@posting.google.c om...
I need to make a union query that returns the results of 2 queries
without combining any fields.
Let me give you an example

Query1
Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 10 0 Electrical Eng.

Query2
Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 0 10 Mech Eng

I want the query to show both records but it tries to put them
together if there is no budget. The query returns the following:

Job WorkOrder Sequence Budget Actuals Employee_Category
1 A000 1000 10 10 Mech Eng

Obviously this doesn't work because the budget was for a Elec Eng and
not a Mech eng.
Any help would be great...
Here is my SQL code...

try UNION ALL instead of UNION

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matias Silva | last post by:
Hi Everyone, I wrote a for loop to build several select statements that are combined with a UNION. When I execute one of the queries separately, it works, but when I execute the query with a UNION...
1
by: Jeff Blee | last post by:
I hope someone can help me get this graph outputing in proper order. After help from Tom, I got a graph to display output from the previous 12 months and include the average of that output all in...
14
by: Salad | last post by:
A97. Situation: I have 3 tables with a text field in each and a date field in the first 2 tables: Table1 Text1, Date1 Table2 Text2, Date2 Table3 Text3 (no date field) The following...
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...
2
by: marco | last post by:
Dear List, as it seems, MS SQL as used in Access does not allow a select INTO within a UNION query. Also, it seems that a UNION query can not be used as a subquery. Maybe my (simplified)...
3
by: mikes | last post by:
I have 2 separate queries, which effectively are the same except they draw data from separate tables. Both tables are (design-wise) identical, only the data is different. for each query, there are...
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...
7
by: KoliPoki | last post by:
Hello every body. I have a small issue. Problem: I have a table with 4 descriptor columns (type). I need to formulate a query to retrieve a count for each type so I can group by...etc. The...
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...
5
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big...
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...

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.