HELP SQL+WHERE+UNION QUERY+Duplicate Entries

hjcksn

Registered User.
Local time
Today, 12:24
Joined
Aug 3, 2012
Messages
4
UNION Query will not execute properly. Remove "WHERE" statement query runs.

The WHERE statement is used to locate all duplicate records, based on serial number, in a table. Also, it excludes certain data contained in two of the four tables. There are four separate queries for four separate tables. They all work until incorporated into a UNION QUERY.

Question, is there another way to structure the "WHERE" statement for this UNION Query and achieve the same results?

Thank you for your time.
 

Attachments

THe only thing I can see that would break a union query are the seperate order by...
A union can only have one Order by, in the last query statement which will apply for the whole recordset.
 
All the "ORDER BY" statements were removed. I should have kept them out and will do so. However, when the "WHERE" were removed, along with the "ORDER BY" statements, the query then processed. Of course not the data desired but the union query was finally in a state to execute.

It was at this point it that the culprit appears to be the "WHERE" statement.

Thank you.
 
really dont see what in the where would break a Union, unless by removing the order by you are breaking the brackets in the process?

You can try re-writing the IN clause to a "proper" join, should be a little faster, otherwize though shouldnt matter.
 
Try building your WHERE clauses into the queries below, or better yet, build another SELECT query that only uses the UNION query as a source. If neither works, your WHERE has an issue.
 
No additonal information, or attachments were noted with your reply.
 
Also, please understand the UNION query was established from four individual select queries that identified duplicate entries from four seperate tables The goal was to combine the individual queries into a UNION query and have all the entries identified in one datasheet.

Thank you.
 

Users who are viewing this thread

Back
Top Bottom