I am working on MS-ACESS 2016, doing queries with different tables.
Something is wrong with this query, the error is:
Syntax error on JOIN operation
The query:
SELECT  r.data                                                      AS data,
        r.cod_treb                                                  AS codi_treballador,
        r.cod_proj                                                  AS codi_projecte,
        r.hores                                                     AS hores_reunions, 
        Nz(ts.hores, 0)                                             AS hores_ts, 
        Iif(r.hores - hores_ts > 0, r.hores - Nz(ts.hores, 0), 0)   AS r_no_fetes 
FROM    reunions r 
        LEFT JOIN   (SELECT tl.*, j.cod_proj, ts.nom_treb, ts.acronim
                    FROM ((((timesheet_lines tl 
                    LEFT JOIN timesheets AS t
                        ON tl.timesheet_id = t.id)
                    LEFT JOIN justificacions AS j 
                        ON t.id_justificacio = j.id)
                    LEFT JOIN treballadors AS tw
                        ON r.cod_treb = tw.cod_treb)
                    LEFT JOIN projectes AS p
                        ON r.cod_proj = p.cod_proj))  AS ts
        ON r.cod_proj = ts.cod_proj
        AND r.cod_treb = ts.cod_treb  
        AND r.data = ts.data
        AND r.cod_treb = ts.cod_treb
        AND r.cod_proj = ts.cod_proj;
If I try to run the subquery (same error)
SELECT tl.*, j.cod_proj, ts.nom_treb, ts.acronim
FROM ((((timesheet_lines tl, reunions r 
    LEFT JOIN timesheets AS t
        ON tl.timesheet_id = t.id)
    LEFT JOIN justificacions AS j 
        ON t.id_justificacio = j.id)
    LEFT JOIN treballadors AS tw
        ON r.cod_treb = tw.cod_treb)
    LEFT JOIN projectes AS p
        ON r.cod_proj = p.cod_proj)  AS ts
    WHERE r.cod_proj = ts.cod_proj
    AND r.cod_treb = ts.cod_treb  
    AND r.data = ts.data
    AND r.cod_treb = ts.cod_treb
    AND r.cod_proj = ts.cod_proj;
Thank you.