Fix SQL join.