Fixed join query for AR.