(
    SELECT *
    FROM users       AS a,
         friendships AS b
    WHERE a.userId     = b.activeId AND
          a.foreignKey = /*activeId*/'' AND
          b.passiveId  = /*passiveId*/0
    LIMIT 0, 1
) UNION ALL (
    SELECT *
    FROM users       AS a,
         friendships AS b
    WHERE a.userId     = b.passiveId AND
          a.foreignKey = /*activeId*/'' AND
          b.activeId  = /*passiveId*/0
    LIMIT 0, 1
)