This is a follow up to my previous question Concatenate 2 rows in a complex SQL query.
Here is what I got from this question:
PARAMETERS [CurrAxe] TEXT ( 255 ), [CurrOTP] TEXT ( 255 ), [CurrClient] TEXT (
255 ), [StartDate] DATETIME, [EndDate] DATETIME;
SELECT q.Projet, *
FROM (faitssaillants f
LEFT JOIN employes e
ON f.utilisateur = e.cip)
INNER JOIN (
SELECT s1.otp,
[s1].[valeur] & "," & [s2].[valeur] AS Projet
FROM (
SELECT otp, valeur
FROM tb_sommaire
WHERE [variable] = 'TitreMandat') AS s1
INNER JOIN (
SELECT otp, valeur
FROM tb_sommaire
WHERE [variable] = 'NomInstallation') AS s2
ON s1.otp = s2.otp) q
ON f.otp = q.otp
WHERE f.otp = [currotp]
AND f.client LIKE [currclient]
AND f.axe LIKE [curraxe]
AND Datevalue([dateinsertion])
Between [startdate] And [enddate]
ORDER BY f.dateinsertion DESC;
What if I would like to add another row (let's name it s3) with [variable] = 'something else' instead of 'TitreMandat' or 'NomInstallation'? Would it be possible to get all the tb_sommaire.variable as fields and tb_sommaire.valeur as values where tb_sommaire.otp = faitssaillants.otp? It would probably fix my future problems too.