Edit: If I change Inner JOIN ids ON ids.id=a.id to INNER JOIN identities ids ON ids.id=a.id then query works on MYSQL (on server directly) But I am not sure where I can change that in code or how I ...