Jump to content

[SOLVED] Get Previous record


GrayFox12

Recommended Posts

Hey i am trying to get the previous record using a query.

 

At the moment i get the next record by using

 

$query0 = "SELECT * FROM SL_Register WHERE IDNumber > '$IDN'";

 

which works fine, so naturally i put the opposite to get the previous record.

 

$query0 = "SELECT * FROM SL_Register WHERE IDNumber < '$IDN'";

 

But this only returns the first record in the table, whereas i want the record that is 1 below the current record, $IDN.  Please help

 

Link to comment
Share on other sites

I would suggest change the id to int for auto increment

you cannot use order by clause to obtain what you need because it will treat your field as char

not numbers 

 

Yes its varchar.

 

Um how would i go about subtracting a character off?

 

You sure there isnt a function in MSSQL i could use.

this idea will waste your time and slow your code although this will work

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.