ALM-379 simplified MySQL query