Verketten Sie 2 Zeilen in einer komplexen SQL-Abfrage

Ich verwende MS-Access 2003 mit dem Abfrageersteller. Ich wähle alles aus einer Tabelle (FaitsSaillants), dann eine bestimmte Zeile (WHERE VARIABLE='TitreMandat') von einem anderen Tisch (tb_SOMMAIRE). Ich möchte eine andere Zeile aus dieser zweiten Tabelle auswählen und verketten.

Die Abfrage
PARAMETERS
    [CurrAxe] Text ( 255 ), [CurrOTP] Text ( 255 ),
    [CurrClient] Text ( 255 ), [StartDate] DateTime, [EndDate] DateTime;
SELECT 
    tb_SOMMAIRE.Valeur AS Projet, tb_SOMMAIRE.VARIABLE, *
FROM
    (FaitsSaillants
     LEFT JOIN Employes
         ON FaitsSaillants.Utilisateur = Employes.CIP)
    INNER JOIN tb_SOMMAIRE
        ON FaitsSaillants.OTP = tb_SOMMAIRE.OTP
WHERE
    (((FaitsSaillants.OTP)=[CurrOTP]) AND 
     ((FaitsSaillants.Client) Like [CurrClient]) AND
     ((FaitsSaillants.Axe) Like [CurrAxe]) AND
     ((DateValue([DateInsertion]))>=[StartDate] AND
      (DateValue([DateInsertion]))<=[EndDate]) AND
     ((tb_SOMMAIRE.VARIABLE)='TitreMandat'))
ORDER BY
    FaitsSaillants.DateInsertion DESC;

Diese Abfrage fügt die hinzutb_SOMMAIRE.Valeur Feld, in dem die IDs (OTP Feld) passen und wotb_SOMMAIRE.VARIABLE='TitreMandat'. Es wirkt wie ein Zauber. Ich möchte jedoch eine weitere Zeile zur Liste hinzufügentb_SOMMAIRE Ergebnisse. Ich möchte die Reihe wo bekommenVARIABLE='TitreMandat' (dieser Teil funktioniert tatsächlich) und die Zeile, in derVARIABLE='NomInstallation'. Ich werde 2 Zeilen bekommen und ich möchte, dass diese 2 Zeilen verkettet und angezeigt werden, wenn ich danach frageProjet (tb_SOMMAIRE.Value as Projet). Beide ReihenOTP (IDs) sind die gleichen wie inFaitsSaillants.

Entschuldigung, wenn es auf Französisch ist.

Tabellenstruktur

FaitsSaillants

Index AutoNumber
Projet Text
Axe Text
Client Text
OTP Text
FaitSaillant Memo
DateInsertion Date
Utilisateur Text

tb_SOMMAIRE

OTP Text
VARIABLE Text
Valeur Text
Datenbeispiel

tb_SOMMAIRE

OTP   VARIABLE        Valeur
UGPSW NomInstallation PosteNemiscau
UGPSW TitreMandat     oscilloperturbographe
UGPSW RespIng         CU9656
GWIHK NomInstallation AnotherInstallation
GWIHK TitreMandat     Anytitle
GWIHK Responsable     ImportantPerson

Antworten auf die Frage(1)

Ihre Antwort auf die Frage