Skip to content
Advertisement

Get previous and next row from rows selected with (WHERE) conditions

For example I have this statement:

This statement is splitted by word, like this table:

I want to get previous and next word of each word

For example I want to get previous and next word of “name”:

How could I get this result?

Advertisement

Answer

you didn’t specify your DBMS, so the following is ANSI SQL:

SQLFiddle: http://sqlfiddle.com/#!12/7639e/1

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement