List:General Discussion« Previous MessageNext Message »
From:Richard Kurth Date:May 11 2007 6:13pm
Subject:RE: finding next and prev record in mysql
View as plain text  
This good for giving me the next recorded but it will not give me the prev
recorded that is the one I am having problems with

You actually do want to use the limit clause, but use 2 parameters. The
first number is which record you want to start at, the second is how many
records you want.
So limit 2,1 will give you the second record. It's the same query every
time, you're just incrementing the first number of the limit clause.

----- Original Message -----
From: "Richard Kurth" <richardkurth@stripped>
To: <mysql@stripped>
Sent: Friday, May 11, 2007 1:15 AM
Subject: finding next and prev record in mysql


> 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
> 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=1

Thread
finding next and prev record in mysqlRichard Kurth11 May
  • Re: finding next and prev record in mysqlBrent Baisley11 May
    • RE: finding next and prev record in mysqlRichard Kurth11 May
  • Re: finding next and prev record in mysqlBaron Schwartz11 May
  • Re: finding next and prev record in mysqlMogens Melander11 May
    • Re: finding next and prev record in mysqlBaron Schwartz11 May
      • RE: finding next and prev record in mysqlRichard Kurth11 May
        • Re: finding next and prev record in mysqlBaron Schwartz12 May