473,382 Members | 1,717 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,382 software developers and data experts.

Losing rows in Union of 2 queries

1,271 Expert 1GB
Using an Access front-end with a SQL Server 2005 backend. I have a query that returns 2 rows. I have a very similar query that returns zero rows. When I union the 2 queries I get one row.

The two rows that are returned by the one query are identical in content. Same customer, same item, same quantity and price.

There is no grouping in either query or the union of the two queries.

If I add invoice number to the Select statements, the two identical rows become unique and the union returns two rows, as I think it should.

Is this an Access bug, or is there something I need to know about how Unions work?

Thanks,
Jim
Feb 18 '11 #1

✓ answered by MikeTheBike

Hi

I think you need UNION ALL, not just UNION

??

MTB

5 5200
MikeTheBike
639 Expert 512MB
Hi

I think you need UNION ALL, not just UNION

??

MTB
Feb 18 '11 #2
jimatqsi
1,271 Expert 1GB
Thanks very much. I didn't know about Union All, or that Union eliminated duplicate entries. Gee, I wonder how many bugs I created with that?

Jim
Feb 18 '11 #3
NeoPa
32,556 Expert Mod 16PB
I don't say this with criticism in mind at all, but you can find some fairly helpful info on Jet SQL, with its options etc, using Finding Jet SQL Help. It's actually not too easy to stumble across, so I hope having it pointed out is helpful.
Feb 19 '11 #4
jimatqsi
1,271 Expert 1GB
Thanks for pointing that insight out to me, Ade. I think that's going to be very helpful. I always used the VBA help and didn't even realize this other was available.

Jim
Feb 21 '11 #5
NeoPa
32,556 Expert Mod 16PB
Always a pleasure Jim. I remember my surprise when I found out how much help was available than I'd previously realised :-)
Feb 21 '11 #6

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

Similar topics

2
by: Brent Wege | last post by:
Hi I have the following union query that retrieves two counts. Can I sum them up within this query, like wrap this in a sum function somehow to get the total count? Or is there a better way to do...
2
by: d2r2 | last post by:
Hi, I'm trying to run a nested (UNION) query against a MSAccessXP database (version 2002; build 10.6501.6714; SP3) In Access the SQL-statement executes just fine. When I run it in a asp-page I...
2
by: Fred Zuckerman | last post by:
I have a union query joining two other queries, each with 62 fields. Interestingly, when I open the query it has the correct number of 2850 records. But if I then set a filter (using filter by...
5
by: Alicia | last post by:
Hello everyone based on the data, I created a union query which produces this. SELECT ,,, 0 As ClosedCount FROM UNION SELECT ,, 0 AS OpenedCount, FROM ORDER BY , ;
1
by: Fl?vio | last post by:
Hey! Please help me... I'd like to know if there's a limit of tables that I can unite in a union query (maybe 16?). When I add more than 16 tables I'm getting an error message. Thank you in...
2
by: Aaron Haspel | last post by:
Greetings Access gurus. I have clients with Access databases in the field that I need to update -- new tables, new indices, new queries, the works. Since these clients may have only the Access...
3
by: Paul H | last post by:
I have been building access databases for a few years now and have never built a union or pass through query. What are these strange mythical beasts? What do they do? Paul
0
by: tdotsmiley | last post by:
Hi, I have multiple union queries that I have. These are from 4 different tables. Is there a way I can use the report feature so that it combines all of the queries into one file so that I can...
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...
2
by: MLH | last post by:
Consider having tblCorrespondence, then copying & pasting it to tblCorrespondence1 - such that they are identical. Then consider the following UNION SELECT statement... SELECT...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?

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.