根据当前的主键查询上一条,下一条数据:
//查询上一条数据
SELECT info_id, headline
FROM b_information
WHERE info_id IN (SELECT CASE
WHEN SIGN(info_id - #{infoId,jdbcType=INTEGER}) < 0 THEN MAX(info_id) END
FROM b_information
WHERE info_id != #{infoId,jdbcType=INTEGER}
GROUP BY SIGN(info_id - #{infoId,jdbcType=INTEGER}));
//查询下一条数据
SELECT info_id, headline
FROM b_information
WHERE info_id IN (SELECT CASE
WHEN SIGN(info_id - #{infoId,jdbcType=INTEGER}) > 0 THEN MIN(info_id) END
FROM b_information
WHERE info_id != #{infoId,jdbcType=INTEGER}
GROUP BY SIGN(info_id - #{infoId,jdbcType=INTEGER}));