Please reply to the list and not to me directly On Thu, Dec 11, 2014 at 5:10 PM, Trianon 33 <triano...@gmail.com> wrote: > > Larry Martell schreef op 11-12-14 om 23:04: >> >> On Thu, Dec 11, 2014 at 4:58 PM, Trianon 33 <triano...@gmail.com> wrote: >>> >>> Larry Martell schreef op 11-12-14 om 22:43: >>>> >>>> On Thu, Dec 11, 2014 at 4:34 PM, Trianon 33 <triano...@gmail.com> wrote: >>>>> >>>>> Hi all, >>>>> >>>>> It seems like a simple question, however I'm not able to find the >>>>> answer..... >>>>> >>>>> Let me explain. I have a DB with lots of columns, one is labeled as >>>>> 'kenteken' and it is also the primary key in the DB. I poke into this >>>>> DB >>>>> with the command >>>>> >>>>> $sDBQuery1 = "SELECT * FROM kentekenlogtest WHERE kenteken = >>>>> '$sActueelkenteken'"; >>>>> >>>>> This is ok and gives me the correct result. However, then I want the >>>>> next >>>>> row (according to the primary key), but with what command? >>>>> >>>>> That's were I'm stuck. >>>>> >>>>> Didn't find anything like NEXT, so... what to look for? >>>> >>>> >>>> What do you mean by 'next' row? Since you're querying by primary key >>>> you will only get one row, right? >>>> >>> Sorry for not expressing me right. >>> >>> Let's say may DB contains the following rowd: >>> >>> 0001ES bla bla bla >>> 0002ES bla bla bla >>> 0010DD bla bla bla >>> 0012FF bla bla bla >>> >>> The first row I retrieve with my statement where my variable >>> $sActueelkenteken = 0001ES. This is succesfully. after that I want the >>> next >>> record which happens to be 0002ES etc. That's the next record I would >>> like >>> to retrieve. >>> >>> Does this help for the question? >> >> The rows in the database are not ordered. What makes 0002ES the row >> you want? You have to change your query to select the rows you want >> and control the order with a sort or within your program. > > Hello Larry, hmmmmm. > > My rows are ordered.
No, the data in the database is not ordered. > 0001ES, comes before 0002ES, etc. But so far that > doesn't really matter. > > My DB consists of approx 10 mio records, all with this 6-digit field > "kenteken" which is 6 positions. All records are sorted by primary key which > is on the field "kenteken". > > All I want to do is select a record (not neccesarily the first in the DB) > and from there I want simply the next record based on the order of the > primary key. Somewhere in the middle I would see record 5555FF, followed by > 5555ZZ for example and somewhere to the end I would see 9999ZZ. > > Makes this explanation it somewhat more understandable? You would have to know the range of the items you want, e.g.: SELECT * FROM kentekenlogtest WHERE kenteken >= $firstOneYouWant and kenteken <= $lastOneYouWant Or if you know how many you want you could do: SELECT * FROM kentekenlogtest WHERE kenteken >= $firstOneYouWant limit $howManyYouWant -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql