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
https://forums.phpfreaks.com/topic/69137-solved-get-previous-record/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.