Here i am trying to load data from TABLE1 to TABLE2.

The requirement is to consider those records in the TABLE1"where TABLE1.COL1=TABLE1.COL1 (OR) TABLE1.COL2=TABLE1.COL2"
As a single group and insert into TABLE2 with COL3 with a unique value for each group thus identified.

TABLE1
~~~~~~
COL1   | COL2 
1      | 11   
1      | 12   
2      | 12   
2      | 13   
111    | 21   
111    | 22   
112    | 22   
112    | 23   

TABLE2
~~~~~~
COL1   | COL2 | COL3
1      | 11   | 201
1      | 12   | 201
2      | 12   | 201
2      | 13   | 201
111    | 21   | 202
111    | 22   | 202
112    | 22   | 202
112    | 23   | 202

Please shed some light on how to use joins to achieve this?

I've tried with self joins but the output is always more than the no of records present in the TABLE1.

Please explain.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.