2017-05-02 5 views
0

Ich habe Probleme beim Abgleich von Daten aus 2 verschiedenen Tabellen. Beispiel Tabelle1: a, b, c, d, e (col) Tab.2: a, d, e, f, g (col)Matching Daten in zwei verschiedenen Tabellen (Daten vergleichen)

Wie mit table2 Daten in Tabelle 1 col a, d, e entsprechen col a, d, e in Bedingung, wenn Zeile in Tabelle1 mit Zeile in Tabelle2 übereinstimmt, dann Schleife stoppen?

In meinem Skript Ergebnis immer duplizieren, während die Daten übereinstimmen (wenn Daten in Tabelle1 seine noch Schleife nicht mit den anderen Daten in Tabelle2 gesperrt).

select distinct x.a, y.a, x.d, y.d, x.e, y.e 
from table1 x, 
    table2 y 
where x.a = y.a(+) and x.d = y.d(+) and x.e = y.e(+) 

leid für mein schlechtes Englisch ...

Edit:

leider kann ich nicht geben gut Smartphone .. vielleicht wie folgt ..

tabelle1

col a--b--c--d--e 
1st_row 'Ryan'--'Sofia'--'Bulgaria'--'January'--'107' 
2nd_row 'Dony'--'Vienna'--'Austria'--'March'--'103' 
3rd_row 'Ryan'--'Berlin'--'Germany'--'January'--'107' 
4th_row 'Dony'--'Milan'--'Italy'--'March'--'103' 

Tabelle2

col a--d--e--f--g 
1st_row 'Ryan'--'January'--'107'--'Travel'--'5' 
2nd_row 'Ryan'--'January'--'107'--'Bussiness'--'4' 
3rd_row 'Dony'--'March'--'103'--'Bussiness'--'9' 
4th_row 'Dony'--'March'--'103'--'Bussiness'--'3' 

in meiner Anfrage

select distinct x.a, y.a, x.d, y.d, x.e, y.e 
from table1 x, 
    table2 y 
where x.a = y.a(+) and x.d = y.d(+) and x.e = y.e(+) 

Ergebnis sind

table1 1st_row matched with table2 1st_row 
table1 2nd_row matched with table2 3rd_row 
table1 3rd_row matched with table2 1st_row (match duplicated) 
table1 4th_row matched with table2 3rd_row (match duplicated) 

aber mein gewünschtes Ergebnis ist tabelle1 1st_row abgestimmt mit table2 1st_row tabelle1 2nd_row abgestimmt mit table2 3rd_row tabelle1 3rd_row abgestimmt mit table2 2nd_row table1 4th_row stimmt mit table2 überein 4th_row

+0

einige Beispieltabellendaten und das erwartete Ergebnis hinzufügen - auch formatierten Text. – jarlh

+0

jarlh bitte überprüfen Sie meine Beispieldaten und erwartetes Ergebnis bei meiner antworteten Antwort, thx – hdy

Antwort

0


können Sie unter Abfrage verwenden

+0

danke jim, morgen werde ich Ihre Abfrage im Büro versuchen – hdy

0


leider kann ich nicht gut Typ Smartphone ..
vielleicht wie dieses ..

tabelle1
col a - b - c-- d - e
1st_row 'Ryan' - 'Sofia' - 'Bulgarien' - 'Januar' - '107'
2nd_row 'Dony' - 'Wien' - 'Österreich' - 'März '-' 103 '
3rd_ Reihe
'Ryan' - 'Berlin' - 'Deutschland' - 'Januar' - '107' 4th_row 'Dony' - 'Mailand' - 'Italien' - 'März' - '103'

table2
col a - d - e - f - g
1st_row 'Ryan' - 'Januar' - '107' - 'Travel' - '5'
2nd_row 'Ryan' - 'Januar' - '107' - 'Bussiness' - '4'
3rd_row 'Dony' - 'März' - '103' - 'Bussiness' - '9'
4th_row 'Dony' - 'März' - '103' - 'Bussiness' - '3'

in meiner Abfrage
selektiere verschiedene x.a, y.a, x.d, y.d, x.e, y.e
aus Tab.1 x, table2 y
wobei xa = ya (+) und xd = yd (+) und Xe = ye (+)
Ergebnis sind
Tabelle1 1st_row mit table2 1st_row abgestimmt
Tabelle1 2nd_row mit table2 3rd_row abgestimmt
tabelle1 3rd_row mit table2 1st_row abgestimmt (Match dupliziert)
tabelle1 4th_row abgestimmt mit table2 3rd_row (Match dupliziert)


aber meinem gewünschten Ergebnis sind
tabelle1 1st_row mit table2 1st_row abgestimmt
tabelle1 2nd_row mit table2 abgestimmt 3rd_row
tabelle1 3rd_row mit table2 abgestimmt 2nd_row
tabelle1 4th_row mit table2 4th_row abgestimmt

Verwandte Themen