MySQL Forums
Forum List  »  Newbie

Neighboring rows
Posted by: Andrew Tran
Date: November 08, 2009 04:31AM

Let's say I have a single column table like this:

Name
----------
Sam
Daniel
Artur
Andrew
Mark
Thomas
Ross
Andrew
Michelle
Adrian
Diane

I want to find the first occurrence of "Andrew", but also the
neighboring rows (like the two rows above the first "Andrew" and the
two rows below the first "Andrew"). This is an example of what I'd
like the query to return:

Daniel
Artur
Andrew
Mark
Thomas

Please keep in mind this is just a demo to illustrate my question;
this is not a real table example!
Thanks a lot!

Options: ReplyQuote


Subject
Written By
Posted
Neighboring rows
November 08, 2009 04:31AM
November 08, 2009 04:54AM
November 08, 2009 05:54AM
November 08, 2009 08:49AM
November 08, 2009 03:56PM
November 08, 2009 05:29PM
November 08, 2009 06:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.