View Full Version : selecting the next record

02-03-2007, 03:46 PM
i am building an application where online orders r passed on to sales agents by sequence. eg. after agent A, B gets the next order then C, D, E etc.....

assuming C got the last order now i have to select the next record from users table(below) i.e D, i need help with the select statement or any hint to solve this.

Users table


02-05-2007, 05:24 PM
If I understand you right, you're going to need some sort of flag to say which agent got the last order. It's difficult to say without understanding more about your application logic but you could, for example, store the name of the last agent to receive an order in an application variable (http://www.w3schools.com/asp/asp_applications.asp) each time you place an order. Then you just need to retrieve that variable each time, apply some simple logic to get the name of the next agent, and use that in your SELECT statement. Make sense?

02-06-2007, 01:53 PM
If your last order holds the agent then you can lookup the last order get the agent then move to the next.

How you do this depends on the design.
If they are A, B, C etc. then you could get the Ascii value of the last agent then add 1. It will get the next letter.