'Double Query lines

I had created a query that worked without issues, which I then modified without saving the original. I do not remember the exact changes I made (I should keep a log, for future references, I know).

Following the changes I made, certain lines are doubled, in spite of the fact that LOTNOis unique per each given BLDNO.

The main table is supposed to be SGLO.

I do not understand why this is happening, as far as I can see from the relationship tree, everyline should be unique. I am therefore posting this in the hope someone from the community may be kind enough to point out my mistake(s).

The code is as follows (broken down by each intended column):

SELECT ANSC_LOC.SOCNAM1 AS Locataire, 
SGBA.ACTV AS Flag_Loc, 
SGBA.CTRDTE AS [Date Signature], 
IIf((CDate(Left([Date Fin],4) & "/" & Mid([Date Fin],5,2) & "/" & Right([Date Fin],2)))<Date(),"Vide",IIf((CDate(Left([Date Fin],4) & "/" & Mid([Date Fin],5,2) & "/" & Right([Date Fin],2)))>Date() And CDate(Left([Date début],4) & "/" & Mid([Date début],5,2) & "/" & Right([Date début],2))>Date(),"Futur","Occupé")) AS Disponibilité, 
SGBA.DEBDTE AS [Date début], 
SGBA.FINDTE AS [Date Fin], 
[SGLO]![LOYBAS] AS [Loyer de base annuel], 
SGBA.LOYBAN, SGBA.LOYBAS, SGBA.LOYPER AS [Périodicité loyer], 
IIf(Format([SGLO]![LOYBAS],"Standard")>0 And [SGBA]![LOYLRVIDX]>0,([SGLO]![LOYBAS]*[SGBA]![LOYLRVIDX]/[SGBA]![IDXBAS]),[SGLO]![LOYBAS]) AS [Loyer actuel annuel indexe], 
IIf([SGBA]![LOYPER]="1" And [SGBA]![LOYBAN]>0,[SGBA]![LOYAPN],IIf([SGBA]![LOYPER]="3" And [SGBA]![LOYBAN]>0,[SGBA]![LOYAPN]/3,IIf([SGBA]![LOYPER]="5" And [SGBA]![LOYBAN]>0,[SGBA]![LOYAPN]/12,IIf([SGBA]![LOYPER]="1" And [SGBA]![LOYBAS]>0,[SGBA]![LOYAPS],IIf([SGBA]![LOYPER]="3" And [SGBA]![LOYBAS]>0,[SGBA]![LOYAPS]/3,IIf([SGBA]![LOYPER]="5" And [SGBA]![LOYBAS]>0,[SGBA]![LOYAPS]/12)))))) AS [Dernier loyer mensuel indexe], 
ANSC_PRO.SOCNAM1 AS Propriétaire, 
ANSC_LOT.SOCNAM1 AS Bâtiment, 
SGLO.BLDNO AS [Code Bâtiment], 
SGLO.LOTNO AS [Numéro Lot], 
SGLO.TYP AS [Code type lot], 
LOTSTYPE.TEXT AS [Type lot], 
[SRF]/100 AS Surface, 
SGLO.SIT AS Adresse, 
SGLO.ETG AS [Code lot], 
SGLO.BLXNO AS [Code Bail], 
SGLO.ETGNUM AS Etage, 
SGLO.QUOTI AS Quotités, 
Photos.[Adresse photo]
FROM 
    (
        (
            (
                (SGLO INNER JOIN ANSC_PRO ON SGLO.PRO = ANSC_PRO.NOTIERS) 
            INNER JOIN SGBA ON SGLO.BLXNO = SGBA.BLXNO) 
        INNER JOIN ANSC_LOC ON SGBA.LOC = ANSC_LOC.NOTIERS) 
    INNER JOIN LOTSTYPE ON SGLO.TYP = LOTSTYPE.LOTTYP) 
INNER JOIN 
    (
        (SGBD INNER JOIN ANSC_LOT ON SGBD.ANSC = ANSC_LOT.NOTIERS) 
    LEFT JOIN Photos ON SGBD.BLDNO = Photos.[Code Immeuble]) ON SGLO.BLDNO = SGBD.BLDNO;

And this is the relationship tree :

Relationship Tree



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source