आपने अपना DBMS निर्दिष्ट नहीं किया है, इसलिए निम्नलिखित ANSI SQL है:
select prev_word, word, next_word
from (
select id,
lag(word) over (order by id) as prev_word,
word,
lead(word) over (order by id) as next_word
from words
) as t
where word = 'name';
SQLFiddle:http://sqlfiddle.com/#!12/7639e/1