MySQL Forums
Forum List  »  PHP

Selecting a range of rows before and after.
Posted by: morten rowley
Date: February 20, 2008 11:05PM

Hi,

I need to return the rows from before and after a specific result.

So I would like to be Select entry "20", and have the entries from "10" to "30" return.

The Two Queries:
"SELECT * FROM journal WHERE date < $selectedDate ORDER BY date DESC LIMIT 10"

"SELECT * FROM journal WHERE date >= $selectedDate ORDER BY date ASC LIMIT 10"

At the moment I'm using these two queries, and it works, but for greater flexibility, is it possible to do with one query?



Edited 1 time(s). Last edit at 02/20/2008 11:05PM by morten rowley.

Options: ReplyQuote




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.