SELECT b.*
FROM users    AS a,
     statuses AS b
WHERE a.userId      = b.senderId AND
      a.protect     = false AND
      /*IF statusIds != null*/statusId      IN /*statusIds*/(0,1,2) AND
      /*END*/b.removedTime = 0
ORDER BY /*IF sortType.givenFavorites*/b.givenFavorites /*$sortOrderType.sortOrder*/DESC, b.statusId DESC
         -- ELSE b.statusId /*$sortOrderType.sortOrder*/DESC/*END*/
LIMIT /*offset*/0, /*limit*/1
