How to get un duplicated records using join of 3 tables with different record numbers?

-1

Hello good afternoon friends, I hope and they are well, I have a problem, I need to make a query sql of two tables both have records with one more than another, I made this query:

SELECT * 
FROM
    ( TVIV056_RELSERIE INNER JOIN TVIV055_INTISERIE ON 
    TVIV056_RELSERIE.CD_SERIE = TVIV055_INTISERIE.CD_SERIE )
    INNER JOIN TVIV053_INVERSION ON TVIV056_RELSERIE.CD_INVERSION = TVIV053_INVERSION.CD_INVERSION

The detail thrown by all the columns and I only need 2 fields that are:

NB_CLAVE | NB_SERIE

The tables are:

table: TVIV055_INTISERIE

In this table they have 51 records.

Table TVIV053_INVERSION

This one has 22 records

I would only need 2 columns and do the combination.

The following code is as such of a java map, that code is already going to be removed and the records that the query that I am developing will be used:

correspondencia.put("A","101");
        correspondencia.put("B","102");
        correspondencia.put("B1","102");
        correspondencia.put("B2","102");
        correspondencia.put("B3","102");
        correspondencia.put("B4","102");
        correspondencia.put("BPR","102");
        correspondencia.put("C","102");
        correspondencia.put("DF","102");
        correspondencia.put("EFA","102");
        correspondencia.put("EXF","102");
        correspondencia.put("GPF","102");
        correspondencia.put("MB","102");
        correspondencia.put("MFA","102");
        correspondencia.put("P","102");
        correspondencia.put("PPR","102");
        correspondencia.put("PV","102");
        correspondencia.put("TF","102");
        correspondencia.put("UHN","102");
        correspondencia.put("B","103");
        correspondencia.put("B-1","103");
        correspondencia.put("B-2","103");
        correspondencia.put("B-3","103");
        correspondencia.put("B-4","103");
        correspondencia.put("B-5","103");
        correspondencia.put("B-6","103");
        correspondencia.put("DM","103");
        correspondencia.put("E","103");
        correspondencia.put("E1","103");
        correspondencia.put("E2","103");
        correspondencia.put("EC","103");
        correspondencia.put("EXM","103");
        correspondencia.put("IF","103");
        correspondencia.put("TM","103");
        correspondencia.put("TM1","103");
        correspondencia.put("DNC","104");
        correspondencia.put("NC","104");
        correspondencia.put("NC1","104");
        correspondencia.put("NC2","104");
        correspondencia.put("NC3","104");
        correspondencia.put("NC4","104");
        correspondencia.put("NC5","104");
        correspondencia.put("NC6","104");
        correspondencia.put("NCC","104");
        correspondencia.put("TNC","104");
        correspondencia.put("TNC1","104");
        correspondencia.put("B","105");
        correspondencia.put("EX","105");
        correspondencia.put("F","107");
        correspondencia.put("GB","108");

But the problem that returns many rows repeated in one of the columns, I hope and can help me, later that I get what I need I would put it to a method and from there to a hashmap in java, but first I want to develop the consult, I hope and you can help me, I remain alert.

Best regards.

    
asked by JUAN JOSE BUSTAMANTE SOLIS 20.04.2018 в 20:13
source

2 answers

0

The problem you have is that there is no way to relate the two tables. The column NB_LARGO would be the one that can be related to NB_CLAVE, but it has the phrase 'ASSOCIATE TO KEY' which ironically does not allow associating it. I think the design of the tables is incorrect. You should create a foreign key to be able to do what you want.

    
answered by 20.04.2018 в 20:16
0

Come out friends, and finish the consultation, in case someone needs it and serve as an example:

SELECT  TVIV055_INTISERIE.NB_SERIE, TVIV053_INVERSION.NB_CLAVE
FROM
    ( TVIV056_RELSERIE INNER JOIN TVIV055_INTISERIE  ON 
    TVIV056_RELSERIE.CD_SERIE = TVIV055_INTISERIE.CD_SERIE )
    INNER JOIN TVIV053_INVERSION  ON TVIV056_RELSERIE.CD_INVERSION = TVIV053_INVERSION.CD_INVERSION

Cordial friends.

    
answered by 24.04.2018 в 00:35