Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exact Duplicate Records in Union Query

Status
Not open for further replies.

lynchg

Programmer
Nov 5, 2003
347
US
I am performing a union query, and the fields and datatypes match up and I produce output. My problem is that I sometimes get exact duplicate records, I would like to eliminate these.

The data I want could be in either of 2 tables, if it is not in the first one then I want to look in the second one to see if it is there. I thought a union would be a good way to get this data, and it is, I just want to eliminate the exact duplicates.

I know I could dump my query results into a temp table and then perform a Select Distinct on that table but I would prefer to get the results in one query.

I would appreciate any suggestions, thanks.
 
Hi,
Be sure to use UNION and not UNION ALL ( this one includes dups)

[profile]

 
I found my problem, there were embedded spaces in one of the fields in one of my tables, so what appeared to be exact duplicates really weren't. I am now trimming the values and I get a distinct set of records.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top