It may help other beginners, so sharing..
====
SELECT @cid := c.categoryid FROM qa_categories c
WHERE c.title = 'SQL Server Interview Questions';
SELECT @nqid := IFNULL(p.postid,0) FROM qa_posts p
WHERE p.type='Q' and p.postid > 1446
AND p.categoryid = @cid
ORDER BY postid LIMIT 1;
SELECT @pqid := IFNULL(p.postid,0) FROM qa_posts p
WHERE p.type='Q' and p.postid < 1446
AND p.categoryid = @cid
ORDER BY postid DESC LIMIT 1;
SELECT @cid, @pqid, @nqid;
===========
SELECT @wid := wordid
FROM qa_words
WHERE word = 'tag1';
SELECT @nqid := IFNULL(p.postid,0) FROM qa_posts p
join qa_posttags pt
on p.postid = pt.postid
WHERE p.type='Q' and p.postid > 1446
AND pt.wordid = @wid
ORDER BY p.postid LIMIT 1;
SELECT @pqid := IFNULL(p.postid,0) FROM qa_posts p
join qa_posttags pt
on p.postid = pt.postid
WHERE p.type='Q' and p.postid < 1446
AND pt.wordid = @wid
ORDER BY p.postid DESC LIMIT 1;
SELECT @wid, @pqid, @nqid;
===========