Mysql - Select next x records even if reaching rowset end
Let me try for a pure SQL solution:

SELECT id
FROM  
   (  ( SELECT *, 0 AS chck
        FROM tableX
        WHERE id &gt; @givenID
        ORDER BY id
        LIMIT 3
      )
    UNION ALL
      ( SELECT *, 1 
        FROM tableX
        WHERE id &lt;= @givenID      -- just in case of a small table (&lt; 3 rows) 
        ORDER BY id
        LIMIT 3
      )
   ) AS t
ORDER BY chck, id
LIMIT 3 ;


Test at SQLfiddle.



The query is basically an improvement on Jehad's answer. It doesn't use a variable (@rank) and the two internal LIMITs will result in improved efficiency on a large table. 

Assuming there is an index on id, the two subqueries will use the index and only need to fetch 3 ids and 3 rows each from the table. The external table (t) after the UNION will have a maximum of 6 rows to sort.