Home  >  Article  >  Backend Development  >  mysql表多列排序,得到某个指定值的上一条或下一条,如何做简单点

mysql表多列排序,得到某个指定值的上一条或下一条,如何做简单点

WBOY
WBOYOriginal
2016-06-13 11:45:041093browse

mysql表多列排序,得到某个指定值的上一条或下一条,怎么做简单点
一个进销存数据库mysql,表名tblsale,有date和index两个字段来确定一个销售单(一天里面有n单,用index来区分),表里面的记录并不一定是按顺序排放,因为存在后面补加的可能。
单纯的对表里的记录进行排序,可以用order by date, index来排(视情况用升序或降序)。
现在前端传过来一个date和一个index,根据这个特定的date和index来找出它的上一单或者下一单。在PHP里,怎么做简单点呢?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:奇葩的异常Next article:下面代码正确的应该如何写