Fixed join in query