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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join returning lot of duplicates 2

Status
Not open for further replies.

MVSTeradata

Programmer
May 4, 2004
6
US
I have 3 tables T375, T378 and T350.

T375 - A1,B1,C1,D1.
the rest of the fields E1,F1 ...etc are not UPI's.

T378 - A1,B1,C1,D1
The rest of the fields E3, F3 are not UPI's and are derived from T375.This table is a child of T375 with the same UPIs.

T350 - A2,B2,C2,D2,E2,F2,G2
The rest of the fields H2,I2 ...etc are not UPI's.


The only way to join T375 and T350 is on other fields
that are not unique.This is the join condition.
substr(A2,1,8) = A1
and B2 = B1
and C2 = E1

This join returns a lot of duplicates.
I need to update T378.E3 field based on the above join condition between T375 and T350.

Whenever i try to update error message says
"Target row updated by more than one source rows"
I need a way to get rid of the duplicates that are returned from the join. I need to update T378 based on the above match. Can someone please come up with a way to weed out the duplicate records.I just need one record returned irrespective of any other conditions.


I will really appreciate all the help that i can get on this one.
Thanks


 
If there are duplicate just use DISTINCT...

Dieter
 
Hi Dieter
I have tried using it but to no avail.
Thansk for replying.
 
If the rows are really duplicates the Distinct should work.

Following your narrative i still don't understand your real problem, it would be easier if you post some data and your query.
Or DDL/Inserts and the expected result set...

Dieter
 
Try running the results to a working SET table, make sure there are no dups, then update the base table using the working table. I agree with Dieter, if distinct or group by doesn't remove dups there is a problem within your SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top