PHQL left join adds same table twice

Hello. I am trying to execute following PHQL: $weekAgoDate = date('Y-m-d', time()-604800);

    $phql = "SELECT
        DISTINCT(s_d.id) as id, s_d.host
    FROM
        OffersDomains o_s_d, Domains s_d
    LEFT JOIN
        ZpDomainStatsUpdated AS d_u
    ON
        s_d.id = d_u.domain_id
    WHERE
    (   d_u.date_updated < '$weekAgoDate'
    OR
        d_u.date_updated IS NULL )
    AND
        o_s_d.domain_id = s_d.id
    AND
        host != ''
    ORDER BY
        d_u.date_updated IS NULL DESC, s_d.id ASC
    LIMIT 1
    ";

I attached a listener and saw the query was converted to following sql: ```sql SELECT DISTINCT (sd.id) AS id, sd.host AS host FROM offersdomains AS osd, domains AS sd LEFT JOIN zpdomainstatsupdated AS du ON sd.id = du.domainid
LEFT JOIN zp
domainstatsupdated AS du ON sd.id = du.domainid WHERE (du.dateupdated < '2016-01-12' OR du.dateupdated IS NULL) AND osd.domainid = id AND sd.host <> '' ORDER BY du.dateupdated IS NULL DESC, id ASC LIMIT 1 ```

As you can see, the zp_domain_stats_updated table joined twice for some reason. How can I avoid this?

Show us your relations and joins in model manager.

edited Jan '16

http://screencast.com/t/qHI5QwyjcDs

Show us your relations and joins in model manager.