MySQL Forums
Forum List  »  German

join Problem
Posted by: Michael Feske
Date: November 04, 2019 02:13AM

Hallo zusammen,
ich habe ein Problem beim Zusammenführen von Daten aus zwei Tabellen. Ich habe eine Tabelle hvb_org_match_schedule.sql hvb_org_match_schedule.sql mit der Struktur:
-- auto-generated definition
create table hvb_org_match_schedule
(
id int auto_increment
primary key,
Termin text null,
Uhrzeit text null,
Verband text null,
Saison text null,
Meisterschaft text null,
Altersklasse text null,
Liga text null,
Staffel text null,
Spieltag text null,
BegegnungNr text null,
HallenNr int(5) null,
HallenName text null,
HeimVereinVerband text null,
HeimVereinNr text null,
HeimVereinName text null,
HeimVereinKurzName text null,
HeimMannschaftAltersklasse text null,
HeimMannschaftNr text null,
HeimMannschaftName text null,
GastVereinVerband text null,
GastVereinNr text null,
GastVereinName text null,
GastVereinKurzName text null,
GastMannschaftAltersklasse text null,
GastMannschaftNr text null,
GastMannschaftName text null,
ToreHeim text null,
ToreGast text null
)
comment 'HVB Vereinsspielplan';
Diese muss ich wöchentlich als CSV (leider manuell importieren).

Und ich habe die Tabelle hvb_beautiful_team_id.sql https://forum.allmendeweg.de/mysql/hvb_beautiful_team_id.sql mit der Struktur:
-- auto-generated definition
create table hvb_beautiful_team_id
(
id int(5) auto_increment
primary key,
Liga text null,
Staffel text null,
GroupId int null,
Championship text null,
Mannschaft text null,
Mannschaft_kurz text null,
Saison int(4) null,
Altersklasse text null
);
Diese wird zum Start der Saison eingespielt.

Ich versuche jetzt für unsere aktiven Mannschaften die entsprechende GroupId zu finden, dazu kommt es allerdings zu Duplikaten, wenn in unserer hvb_beautiful_team_id eine Hin / Rückrunde auftaucht.

Mein bisheriger Ansatz ist:
select schedule.id, schedule.Termin, schedule.Uhrzeit, Meisterschaft, schedule.Altersklasse, schedule.Liga, schedule.Staffel, schedule.Spieltag, schedule.BegegnungNr, teamLiga.id, teamLiga.Liga, teamLiga.Staffel, teamLiga.GroupId
from hvb_org_match_schedule schedule
inner join hvb_beautiful_team_id teamLiga
on schedule.Liga = concat(teamLiga.Liga," ",teamLiga.Altersklasse)
left join hvb_beautiful_team_id teamStaffel
on concat(schedule.Staffel, teamStaffel.Staffel) = concat(teamStaffel.Staffel)
where teamLiga.Mannschaft_kurz is not null

Könnt ihr mir vielleicht helfen das Problem zu fixen ?

Gruß
Micha

Options: ReplyQuote


Subject
Views
Written By
Posted
join Problem
517
November 04, 2019 02:13AM
235
November 04, 2019 02:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.