| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Baron Schwartz | Date: | May 11 2007 3:41pm |
| Subject: | Re: finding next and prev record in mysql | ||
| View as plain text | |||
Hi, Richard Kurth wrote: > How would I find the next id and the prev id in sql statement like the one > below. The id number is not going to be in order so I can't do a < or > > limit 1 on the search > > SELECT id FROM contacts WHERE category = '5' AND subcategory = '1' AND > members_id= '8' ORDER BY lastname > I wrote about some solutions that work for me, here: http://www.xaprb.com/blog/2006/04/28/how-to-find-next-and-previous-records-in-sql/ I don't know if you need to do this without subqueries or not, but the methods I explain work on MySQL 3.23. I hope that helps. -- Baron Schwartz http://www.xaprb.com/
| Thread | ||
|---|---|---|
| • finding next and prev record in mysql | Richard Kurth | 11 May |
| • Re: finding next and prev record in mysql | Brent Baisley | 11 May |
| • RE: finding next and prev record in mysql | Richard Kurth | 11 May |
| • Re: finding next and prev record in mysql | Baron Schwartz | 11 May |
| • Re: finding next and prev record in mysql | Mogens Melander | 11 May |
| • Re: finding next and prev record in mysql | Baron Schwartz | 11 May |
| • RE: finding next and prev record in mysql | Richard Kurth | 11 May |
| • Re: finding next and prev record in mysql | Baron Schwartz | 12 May |
