(
    SELECT b.*
    FROM users       AS a,
         friendships AS b,
         users       AS c
    WHERE a.userId      = b.activeId AND
          c.userId      = b.passiveId AND
          a.remove      = false AND
          b.passiveId   = /*passiveId*/0 AND
          b.accept      = true AND
          b.removedTime = 0 AND
          c.protect     = true AND
          c.remove      = false
    ORDER BY activeId
) UNION ALL (
    SELECT b.*
    FROM users       AS a,
         friendships AS b,
         users       AS c
    WHERE a.userId      = b.activeId AND
          c.userId      = b.passiveId AND
          a.remove      = false AND
          b.passiveId   = /*passiveId*/0 AND
          b.removedTime = 0 AND
          c.protect     = false AND
          c.remove      = false
    ORDER BY activeId
)
ORDER BY activeId
LIMIT /*offset*/0, /*limit*/1
