MySQL Forums
Forum List  »  Optimizer & Parser

best way to create 'next' and 'previous' text
Posted by: Johannes Fosseus
Date: September 10, 2006 01:53AM

Hi again

Sorry for writing som many questions this day, this is my last one!

I have a 'next' and 'previous' textId function on my site, no problem. Still I do think that there must exist a better way to find the 'next' and 'previous' then the one I use.

My slution: My sql returns alla text the last day, then i put them in an array and step +1 or -1 in the array. I find in overkill to let mysql return like 500 text when I only need one row?

SELECT textId
FROM junior_text
WHERE textcreatedlong >= DATE_ADD( '2006-08-09', INTERVAL -1 DAY )
AND textcreatedlong <= DATE_ADD( '2006-08-09', INTERVAL +1 DAY )
AND textactive = 1
ORDER BY textcreatedlong DESC

Any suggestions to optimize this operation?

best regards / johannes

Options: ReplyQuote


Subject
Views
Written By
Posted
best way to create 'next' and 'previous' text
2585
September 10, 2006 01:53AM


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.