如果我单击数字5的链接,我希望能够获得数字4和6的链接。 如果每行的num值不是连续的(例如1、3、5、6、7、9等),则不直接加1并减去1。此外,我想同时使用关键字搜索选项。另外,它将在Mybatis环境下使用。如何将下面的源代码转换为MySql?
<select id="getData2" parameterType="cafeDto" resultType="cafeDto">
SELECT result1.*
FROM (SELECT num, writer, title, content, viewCount, regdate,
LAG(num, 1, 0) OVER(ORDER BY num DESC) prevNum,
LEAD(num, 1, 0) OVER(ORDER BY num DESC) nextNum
FROM board_cafe
<where>
<if test="writer != null">
OR writer LIKE '%'||#{writer}||'%'
</if>
<if test="title != null">
OR title LIKE '%'||#{title}||'%'
</if>
<if test="content != null">
OR content LIKE '%'||#{content}||'%'
</if>
</where>
ORDER BY num DESC) result1
WHERE num=#{num}
</select>